package com.tjtt.gwm.action;

import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.PrintWriter;
import java.sql.Timestamp;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletResponse;

import net.sf.json.JSONArray;
import net.sf.json.JSONObject;

import org.apache.struts2.ServletActionContext;
import org.springframework.web.context.WebApplicationContext;
import org.springframework.web.context.support.WebApplicationContextUtils;

import com.tjtt.common.gps.BLH;
import com.tjtt.common.gps.CoordTranf;
import com.tjtt.common.gps.Four_Par;
import com.tjtt.common.gps.GpsUtil;
import com.tjtt.common.gps.xyh;
import com.tjtt.common.utils.TotalFlowXmlTool;
import com.tjtt.gwm.bean.Junyans;
import com.tjtt.gwm.bean.Junyansceshis;
import com.tjtt.gwm.bean.Junyansshejis;
import com.tjtt.gwm.service.DbService;
import com.tjtt.gwm.service.EquipmentService;
import com.tjtt.gwm.service.GuanxianService;
import com.tjtt.gwm.service.JunyansService;
import com.tjtt.tdm.base.BaseAction;
import com.tjtt.tdm.base.PageResult;
import com.tjtt.tdm.base.StringUtil;
import com.tjtt.tdm.codeReview.service.ICodeReviewService;
import com.tjtt.tdm.flow.bean.FlowDetailed;
import com.tjtt.tdm.flow.service.IFlowformService;
import com.tjtt.tdm.util.MapUtil;
import com.tjtt.tdm.util.PubMethod;
import com.tjtt.tdm.util.WordTool;

public class GuanxianAction extends BaseAction {
	private GuanxianService guanxianService;
	private DbService dbService;
	
	public GuanxianService getGuanxianService() {
		return guanxianService;
	}
	public void setGuanxianService(GuanxianService guanxianService) {
		this.guanxianService = guanxianService;
	}
	public DbService getDbService() {
		return dbService;
	}
	public void setDbService(DbService dbService) {
		this.dbService = dbService;
	}
	
	//生成节点
	public JSONObject GenerateNode(String id,String pId,String name,boolean isParent) throws IOException{
		JSONObject root = new JSONObject();
		root.put("id", id);
		root.put("pId", pId);
		root.put("name", name);
		root.put("isParent", isParent);
		//root.put("open", true);
		return root;
	}
	
	//获取父节点
	public JSONArray getNodesParent(String pipeLineNO,String nodetypes,
			String nodetype,String rootidPrefix,String rootName,
			List<String> nodetypeChildList,List<String> rootNameChildList,
			List<String> tablenameChildList,List<String> fieldnameChildList
			) throws IOException{
		JSONArray jsonArray = new JSONArray();		
		int childnum=nodetypeChildList.size();
		String id="";		
		JSONArray jsonArrayTemp;
		if (nodetypes.indexOf(nodetype)>=0){
			JSONObject root = GenerateNode(rootidPrefix+pipeLineNO,"gx"+pipeLineNO,rootName,true);
			jsonArray.add(root);						
			for(int i=0;i<childnum;i++)
			{	
				String childType=nodetypeChildList.get(i);
				String rootPrefixChild=childType+"Root";
				String rootNameChild=rootNameChildList.get(i);
				String tablenameChild=tablenameChildList.get(i);
				String fieldnameChild=fieldnameChildList.get(i);
				id=rootPrefixChild+pipeLineNO;
				JSONObject santongdroot = GenerateNode(id,rootidPrefix+pipeLineNO,rootNameChild,true);
				jsonArray.add(santongdroot);
				//子节点		
				if(childType.equals("xljcxld")) //泄漏检测泄漏点
				{
					jsonArrayTemp=getNodeXljcxld(id,"xljcxldRoot","ptem_leak_test","id","LOCATIONY,LOCATIONX");	
				}
				else
				{
					jsonArrayTemp=getNode(id,rootPrefixChild,tablenameChild,fieldnameChild);
				}				
				int num=jsonArrayTemp.size();
				for(int j=0;j<num;j++)
				{
					JSONObject json=jsonArrayTemp.getJSONObject(j);
					jsonArray.add(json);
				}
			}			
		}
		if (nodetypes.indexOf(nodetype)<0){
			int i=0;
			for(i=0;i<childnum;i++)
			{
				String childType=nodetypeChildList.get(i);				
				if(nodetypes.indexOf(childType)>=0)
				{
					break;
				}
			}
			if(i==childnum)
			{
				return jsonArray;
			}			
			//勾选了三通、套管或弯管
			JSONObject root = GenerateNode(rootidPrefix+pipeLineNO,"gx"+pipeLineNO,rootName,true);
			jsonArray.add(root);
			for(i=0;i<childnum;i++)
			{
				String childType=nodetypeChildList.get(i);	
				String rootPrefixChild=childType+"Root";
				String rootNameChild=rootNameChildList.get(i);
				String tablenameChild=tablenameChildList.get(i);
				String fieldnameChild=fieldnameChildList.get(i);
				if (nodetypes.indexOf(childType)>=0){
					id=rootPrefixChild+pipeLineNO;
					JSONObject santongdroot = GenerateNode(id,rootidPrefix+pipeLineNO,rootNameChild,true);
					jsonArray.add(santongdroot);
					//子节点				
					jsonArrayTemp=getNode(id,rootPrefixChild,tablenameChild,fieldnameChild);
					int num=jsonArrayTemp.size();
					for(int j=0;j<num;j++)
					{
						JSONObject json=jsonArrayTemp.getJSONObject(j);
						jsonArray.add(json);
					}
				}
			}
		}	
		return jsonArray;
	}
	//获取父节点
	public JSONArray getNodesParent(String pipeLineNO,String nodetypes,
			String nodetype,String rootidPrefix,String rootName,
			List<String> nodetypeChildList,List<String> rootNameChildList,
			List<String> tablenameChildList,List<String> fieldnameChildList,
			List<String> fieldnameChildListDis) throws IOException{
		JSONArray jsonArray = new JSONArray();		
		int childnum=nodetypeChildList.size();
		String id="";		
		JSONArray jsonArrayTemp;
		if (nodetypes.indexOf(nodetype)>=0){
			JSONObject root = GenerateNode(rootidPrefix+pipeLineNO,"gx"+pipeLineNO,rootName,true);
			jsonArray.add(root);						
			for(int i=0;i<childnum;i++)
			{	
				String childType=nodetypeChildList.get(i);
				String rootPrefixChild=childType+"Root";
				String rootNameChild=rootNameChildList.get(i);
				String tablenameChild=tablenameChildList.get(i);
				String fieldnameChild=fieldnameChildList.get(i);
				String fieldnameChildDis=fieldnameChildListDis.get(i);
				id=rootPrefixChild+pipeLineNO;
				JSONObject santongdroot = GenerateNode(id,rootidPrefix+pipeLineNO,rootNameChild,true);
				jsonArray.add(santongdroot);
				//子节点		
				if(childType.equals("xljcxld")) //泄漏检测泄漏点
				{
					jsonArrayTemp=getNodeXljcxld(id,"xljcxldRoot","ptem_leak_test","id","LOCATIONY,LOCATIONX");	
				}
				else
				{
					if(tablenameChild.equals("ptem_operations_data"))
					{
						jsonArrayTemp=getNodeOperation(id,rootPrefixChild,tablenameChild,fieldnameChild,fieldnameChildDis);						
					}
					else if(tablenameChild.equals("ptem_emergency_data"))
					{
						String tablenameparent="PTEM_EMERGENCY";
						jsonArrayTemp=getNodeChild(id,rootPrefixChild,tablenameChild,fieldnameChild,fieldnameChildDis,tablenameparent);											
					}				
					else{
						jsonArrayTemp=getNode(id,rootPrefixChild,tablenameChild,fieldnameChild,fieldnameChildDis);					
					}
				}				
				int num=jsonArrayTemp.size();
				for(int j=0;j<num;j++)
				{
					JSONObject json=jsonArrayTemp.getJSONObject(j);
					jsonArray.add(json);
				}
			}			
		}
		if (nodetypes.indexOf(nodetype)<0){
			int i=0;
			for(i=0;i<childnum;i++)
			{
				String childType=nodetypeChildList.get(i);				
				if(nodetypes.indexOf(childType)>=0)
				{
					break;
				}
			}
			if(i==childnum)
			{
				return jsonArray;
			}			
			//勾选了三通、套管或弯管
			JSONObject root = GenerateNode(rootidPrefix+pipeLineNO,"gx"+pipeLineNO,rootName,true);
			jsonArray.add(root);
			for(i=0;i<childnum;i++)
			{
				String childType=nodetypeChildList.get(i);	
				String rootPrefixChild=childType+"Root";
				String rootNameChild=rootNameChildList.get(i);
				String tablenameChild=tablenameChildList.get(i);
				String fieldnameChild=fieldnameChildList.get(i);
				String fieldnameChildDis=fieldnameChildListDis.get(i);
				if (nodetypes.indexOf(childType)>=0){
					id=rootPrefixChild+pipeLineNO;
					JSONObject santongdroot = GenerateNode(id,rootidPrefix+pipeLineNO,rootNameChild,true);
					jsonArray.add(santongdroot);
					
					
					//子节点	
					if(childType.equals("xljcxld")) //泄漏检测泄漏点
					{
						jsonArrayTemp=getNodeXljcxld(id,"xljcxldRoot","ptem_leak_test","id","LOCATIONY,LOCATIONX");	
					}
					else
					{
						if(tablenameChild.equals("ptem_operations_data"))
						{
							jsonArrayTemp=getNodeOperation(id,rootPrefixChild,tablenameChild,fieldnameChild,fieldnameChildDis);						
						}
						else if(tablenameChild.equals("ptem_emergency_data"))
						{
							String tablenameparent="PTEM_EMERGENCY";
							jsonArrayTemp=getNodeChild(id,rootPrefixChild,tablenameChild,fieldnameChild,fieldnameChildDis,tablenameparent);											
						}
						else
						{
							jsonArrayTemp=getNode(id,rootPrefixChild,tablenameChild,fieldnameChild,fieldnameChildDis);						
						}
					}
					
					int num=jsonArrayTemp.size();
					for(int j=0;j<num;j++)
					{
						JSONObject json=jsonArrayTemp.getJSONObject(j);
						jsonArray.add(json);
					}
				}
			}
		}	
		return jsonArray;
	}
	//获取叶子节点
	public JSONArray getNodesLeaf(String pipeLineNO,String nodetypes,
			String nodetype,String rootidPrefix,String rootName,
			String tablename,String fieldname) throws IOException{
		JSONArray jsonArray = new JSONArray();
		String id="";
		int num;
		JSONArray jsonArrayTemp;
		if (nodetypes.indexOf(nodetype)>=0){
			JSONObject tezhengdroot = GenerateNode(rootidPrefix+pipeLineNO,"gx"+pipeLineNO,rootName,true);
			jsonArray.add(tezhengdroot);
			//子节点
			id=rootidPrefix+pipeLineNO;
			jsonArrayTemp=getNode(id,rootidPrefix,tablename,fieldname);
			num=jsonArrayTemp.size();
			for(int j=0;j<num;j++)
			{
				JSONObject json=jsonArrayTemp.getJSONObject(j);
				jsonArray.add(json);
			}
		}
		return jsonArray;
	}
	public JSONArray getNodesLeaf(String pipeLineNO,String nodetypes,
			String nodetype,String rootidPrefix,String rootName,
			String tablename,String fieldname,String fieldnameDis) throws IOException{
		JSONArray jsonArray = new JSONArray();
		String id="";
		int num;
		JSONArray jsonArrayTemp;
		if (nodetypes.indexOf(nodetype)>=0){
			JSONObject tezhengdroot = GenerateNode(rootidPrefix+pipeLineNO,"gx"+pipeLineNO,rootName,true);
			jsonArray.add(tezhengdroot);
			//子节点
			id=rootidPrefix+pipeLineNO;
			jsonArrayTemp=getNode(id,rootidPrefix,tablename,fieldname,fieldnameDis);
			num=jsonArrayTemp.size();
			for(int j=0;j<num;j++)
			{
				JSONObject json=jsonArrayTemp.getJSONObject(j);
				jsonArray.add(json);
			}
		}
		return jsonArray;
	}
	//生产作业
	public JSONArray getShengchanzuoyeNode(String pipeLineNO,String nodetypes)throws IOException{
		JSONArray jsonArray = new JSONArray();
		List<String> nodetypeChildList=new ArrayList();		
		List<String> rootNameChildList=new ArrayList();
		List<String> tablenameChildList=new ArrayList();
		List<String> fieldnameChildList=new ArrayList();
		List<String> fieldnameChildListDis=new ArrayList();
		nodetypeChildList.add("shengchanzyd");
		nodetypeChildList.add("dqzyjxyzh");		
		rootNameChildList.add("生产作业点");
		rootNameChildList.add("带气作业机械预制件");
		tablenameChildList.add("ptem_operations_data");
		tablenameChildList.add("ptem_fitting");
		//fieldnameChildList.add("pipeno");
		fieldnameChildList.add("ID");//结构树ID
		fieldnameChildListDis.add("EVENTNO"); //结构树显示字段
		//fieldnameChildList.add("EVENTNO");
		fieldnameChildList.add("ID");//结构树ID
		fieldnameChildListDis.add("EVENTNO"); //结构树显示字段
//		jsonArray=getNodesParent(pipeLineNO,nodetypes,"shchzy",
//				"shchzyRoot","生产作业",nodetypeChildList,rootNameChildList,
//				tablenameChildList,fieldnameChildList);
		jsonArray=getNodesParent(pipeLineNO,nodetypes,"shchzy",
				"shchzyRoot","生产作业",nodetypeChildList,rootNameChildList,
				tablenameChildList,fieldnameChildList,fieldnameChildListDis);
		return jsonArray;
	}
	//生产运行
	public JSONArray getShengchanyunxingNode(String pipeLineNO,String nodetypes)throws IOException{
		JSONArray jsonArray = new JSONArray();
		List<String> nodetypeChildList=new ArrayList();		
		List<String> rootNameChildList=new ArrayList();
		List<String> tablenameChildList=new ArrayList();
		List<String> fieldnameChildList=new ArrayList();
		nodetypeChildList.add("yichang");
		nodetypeChildList.add("teshuduan");
		nodetypeChildList.add("wzzy");
		rootNameChildList.add("异常");
		rootNameChildList.add("特殊段");
		rootNameChildList.add("违章占压");
		tablenameChildList.add("ptem_exception");
		tablenameChildList.add("ptem_special");
		tablenameChildList.add("ptem_violation");
		fieldnameChildList.add("EXCEPTIONNO");
		fieldnameChildList.add("SPECIALNO");
		fieldnameChildList.add("VIOLATIONNO");
		jsonArray=getNodesParent(pipeLineNO,nodetypes,"shchyx",
				"shchyxRoot","生产运行",nodetypeChildList,rootNameChildList,
				tablenameChildList,fieldnameChildList);
		return jsonArray;
	}
	//附属设施
	public JSONArray getFushusheshiNode(String pipeLineNO,String nodetypes)throws IOException{
		JSONArray jsonArray = new JSONArray();
		List<String> nodetypeChildList=new ArrayList();		
		List<String> rootNameChildList=new ArrayList();
		List<String> tablenameChildList=new ArrayList();
		List<String> fieldnameChildList=new ArrayList();
		nodetypeChildList.add("pointAnode");
		nodetypeChildList.add("pointPole");
		nodetypeChildList.add("pointDrainage");
		rootNameChildList.add("阳极");
		rootNameChildList.add("测试桩");
		rootNameChildList.add("排流装置");
		tablenameChildList.add("ptem_point_anode");
		tablenameChildList.add("ptem_point_pole");
		tablenameChildList.add("ptem_point_drainage");
		fieldnameChildList.add("anodeno");
		fieldnameChildList.add("poleno");
		fieldnameChildList.add("DRAINAGECODE");
//		jsonArray=getNodesParent(pipeLineNO,nodetypes,"fushuss",
//				"fsssroot","附属设施",nodetypeChildList,rootNameChildList,
//				tablenameChildList,fieldnameChildList);
		jsonArray=getNodesParent(pipeLineNO,nodetypes,"fushuss",
				"fushussRoot","附属设施",nodetypeChildList,rootNameChildList,
				tablenameChildList,fieldnameChildList);
		return jsonArray;
	}
	//管件
	public JSONArray getGuanjianNode(String pipeLineNO,String nodetypes)throws IOException{
		JSONArray jsonArray = new JSONArray();
		List<String> nodetypeChildList=new ArrayList();		
		List<String> rootNameChildList=new ArrayList();
		List<String> tablenameChildList=new ArrayList();
		List<String> fieldnameChildList=new ArrayList();
		nodetypeChildList.add("pointTee");
		nodetypeChildList.add("taoguan");
		nodetypeChildList.add("wanguan");
		rootNameChildList.add("三通");
		rootNameChildList.add("套管");
		rootNameChildList.add("弯管");
		tablenameChildList.add("ptem_point_tee");
		tablenameChildList.add("ptem_point_casing");
		tablenameChildList.add("ptem_point_bend");
		fieldnameChildList.add("teeno");
		fieldnameChildList.add("casingno");
		fieldnameChildList.add("bendno");
		jsonArray=getNodesParent(pipeLineNO,nodetypes,"guanjian",
				"guanjianroot","管件",nodetypeChildList,rootNameChildList,
				tablenameChildList,fieldnameChildList);
		return jsonArray;
	}
	//事件
	public JSONArray getShjianNode(String pipeLineNO,String nodetypes)throws IOException{
		JSONArray jsonArray = new JSONArray();
		List<String> nodetypeChildList=new ArrayList();		
		List<String> rootNameChildList=new ArrayList();
		List<String> tablenameChildList=new ArrayList();
		List<String> fieldnameChildList=new ArrayList();
		List<String> fieldnameChildListDis=new ArrayList();
		nodetypeChildList.add("sjd");
		nodetypeChildList.add("xld");		
		rootNameChildList.add("事件点");
		rootNameChildList.add("泄漏点");
		//tablenameChildList.add("ptem_emergency");
		tablenameChildList.add("ptem_emergency_data");
		tablenameChildList.add("ptem_leakpoint");
		//fieldnameChildList.add("EVENTNO");
		fieldnameChildList.add("ID");
		fieldnameChildListDis.add("EVENTNO");
		fieldnameChildList.add("ID");
		fieldnameChildListDis.add("EVENNO");
		jsonArray=getNodesParent(pipeLineNO,nodetypes,"shijian",
				"shijianRoot","事件",nodetypeChildList,rootNameChildList,
				tablenameChildList,fieldnameChildList,fieldnameChildListDis);
		return jsonArray;
	}
	//直接检查
	public JSONArray getZhijiejianchaNode(String pipeLineNO,String nodetypes)throws IOException{		
		JSONArray jsonArray = new JSONArray();
		List<String> nodetypeChildList=new ArrayList();		
		List<String> rootNameChildList=new ArrayList();
		List<String> tablenameChildList=new ArrayList();
		List<String> fieldnameChildList=new ArrayList();
		List<String> fieldnameChildListDis=new ArrayList();
		nodetypeChildList.add("wgjch");
		nodetypeChildList.add("bhjc");	
		nodetypeChildList.add("ffchdjc");
		nodetypeChildList.add("ffcpsjc");
		nodetypeChildList.add("fshzhkjc");
		nodetypeChildList.add("shexianjc");
		rootNameChildList.add("外观检查");
		rootNameChildList.add("壁厚检测");
		rootNameChildList.add("防腐层厚度检测");
		rootNameChildList.add("防腐层破损检测");
		rootNameChildList.add("腐蚀状况检测");
		rootNameChildList.add("射线检测");
		tablenameChildList.add("ptem_apperance_check");
		tablenameChildList.add("ptem_wallthickness");
		tablenameChildList.add("ptem_coatingthickness");
		tablenameChildList.add("ptem_coatingdamaged_test");
		tablenameChildList.add("ptem_corrosion_test");
		tablenameChildList.add("ptem_radial");
		fieldnameChildList.add("ID");
		fieldnameChildList.add("ID");
		fieldnameChildList.add("ID");
		fieldnameChildList.add("ID");
		fieldnameChildList.add("ID");
		fieldnameChildList.add("ID");
		fieldnameChildListDis.add("LOCATIONNO");
		fieldnameChildListDis.add("LOCATIONNO");
		fieldnameChildListDis.add("LOCATIONNO");
		fieldnameChildListDis.add("LOCATIONNO");
		fieldnameChildListDis.add("LOCATIONNO");
		fieldnameChildListDis.add("LOCATIONNO");
		jsonArray=getNodesParent(pipeLineNO,nodetypes,"zhjjch",
				"zhjjchRoot","直接检查",nodetypeChildList,rootNameChildList,
				tablenameChildList,fieldnameChildList,fieldnameChildListDis);
		return jsonArray;
	}
	//专项检测
	public JSONArray getZhuanxiangjianchaNode(String pipeLineNO,String nodetypes)throws IOException{
		JSONArray jsonArray = new JSONArray();
		List<String> nodetypeChildList=new ArrayList();		
		List<String> rootNameChildList=new ArrayList();
		List<String> tablenameChildList=new ArrayList();
		List<String> fieldnameChildList=new ArrayList();	
		List<String> fieldnameChildListDes=new ArrayList();
		nodetypeChildList.add("dbjc");
		nodetypeChildList.add("cjyjc");
		nodetypeChildList.add("shbdcjc");
		rootNameChildList.add("导波检测");
		rootNameChildList.add("磁记忆检测");
		rootNameChildList.add("瞬变电磁检测");
		tablenameChildList.add("PTEM_GUIDEDWAVES_TEST");
		tablenameChildList.add("PTEM_MAGNETIC_TEST");
		tablenameChildList.add("ptem_tdem_test");
		
		fieldnameChildList.add("ID");
		fieldnameChildList.add("ID");
		fieldnameChildList.add("ID");
		
		fieldnameChildListDes.add("LOCATIONNO");
		fieldnameChildListDes.add("LOCATIONNO");
		fieldnameChildListDes.add("PIPENO");
		
		jsonArray=getNodesParent(pipeLineNO,nodetypes,"zhxjc",
				"zhxjcRoot","专项检测",nodetypeChildList,rootNameChildList,
				tablenameChildList,fieldnameChildList,fieldnameChildListDes);
		return jsonArray;
	}
	//泄漏检测
	public JSONArray getXieloujianceNode(String pipeLineNO,String nodetypes)throws IOException{
		JSONArray jsonArray = new JSONArray();
		List<String> nodetypeChildList=new ArrayList();		
		List<String> rootNameChildList=new ArrayList();
		List<String> tablenameChildList=new ArrayList();
		List<String> fieldnameChildList=new ArrayList();
		List<String> fieldnameChildListDes=new ArrayList();
		nodetypeChildList.add("xljcjcd");
		nodetypeChildList.add("xljcxld");		
		rootNameChildList.add("检测点");
		rootNameChildList.add("泄漏点");
		tablenameChildList.add("ptem_leak_test");
		tablenameChildList.add("ptem_leak_test");
		fieldnameChildList.add("ID");
		fieldnameChildList.add("ID");
		fieldnameChildListDes.add("LOCATIONY,LOCATIONX");
		fieldnameChildListDes.add("LOCATIONY,LOCATIONX");
		jsonArray=getNodesParent(pipeLineNO,nodetypes,"xieloujc",
				"xieloujcRoot","泄漏检测",nodetypeChildList,rootNameChildList,
				tablenameChildList,fieldnameChildList,fieldnameChildListDes);
		return jsonArray;
	}
	//理化检测
	public JSONArray getLihuajianceNode(String pipeLineNO,String nodetypes)throws IOException{
		JSONArray jsonArray = new JSONArray();
		List<String> nodetypeChildList=new ArrayList();		
		List<String> rootNameChildList=new ArrayList();
		List<String> tablenameChildList=new ArrayList();
		List<String> fieldnameChildList=new ArrayList();
		List<String> fieldnameChildListDes=new ArrayList();
		nodetypeChildList.add("ylshy");
		nodetypeChildList.add("hxchffx");	
		nodetypeChildList.add("ydcsh");
		nodetypeChildList.add("jxfx");
		nodetypeChildList.add("lshshy");
		nodetypeChildList.add("wqshiy");
		nodetypeChildList.add("chjshy");
		rootNameChildList.add("应力试验");
		rootNameChildList.add("化学成分分析");
		rootNameChildList.add("硬度测试");
		rootNameChildList.add("金相分析");
		rootNameChildList.add("拉伸试验");	
		rootNameChildList.add("弯曲试验");
		rootNameChildList.add("冲击试验");
		tablenameChildList.add("ptem_remainingstress");
		tablenameChildList.add("ptem_chemical");
		tablenameChildList.add("ptem_hardness");
		tablenameChildList.add("ptem_metallographic");
		tablenameChildList.add("ptem_stretch");
		tablenameChildList.add("ptem_bend");
		tablenameChildList.add("ptem_shock");
		
		fieldnameChildList.add("ID");
		fieldnameChildList.add("ID");
		fieldnameChildList.add("ID");
		fieldnameChildList.add("ID");
		fieldnameChildList.add("ID");
		fieldnameChildList.add("ID");
		fieldnameChildList.add("ID");
		
		fieldnameChildListDes.add("LOCATIONNO");
		fieldnameChildListDes.add("LOCATIONNO");
		fieldnameChildListDes.add("LOCATIONNO");
		fieldnameChildListDes.add("LOCATIONNO");
		fieldnameChildListDes.add("LOCATIONNO");
		fieldnameChildListDes.add("LOCATIONNO");
		fieldnameChildListDes.add("LOCATIONNO");
		jsonArray=getNodesParent(pipeLineNO,nodetypes,"lhjc",
				"lhjcRoot","理化检测",nodetypeChildList,rootNameChildList,
				tablenameChildList,fieldnameChildList,fieldnameChildListDes);
		return jsonArray;
	}
	//腐蚀防护系统检测
	public JSONArray getFushifanghuxitongjianceNode(String pipeLineNO,String nodetypes)throws IOException{
		JSONArray jsonArray = new JSONArray();
		List<String> nodetypeChildList=new ArrayList();		
		List<String> rootNameChildList=new ArrayList();
		List<String> tablenameChildList=new ArrayList();
		List<String> fieldnameChildList=new ArrayList();
		List<String> fieldnameChildListDes=new ArrayList();
		nodetypeChildList.add("trfshxjc");
		nodetypeChildList.add("zsdljc");	
		//nodetypeChildList.add("ffcjydz");
		nodetypeChildList.add("ffcjcd");
		nodetypeChildList.add("ffcpsd");
		nodetypeChildList.add("cshzhjc");
		//nodetypeChildList.add("yjbhxgjc");
		nodetypeChildList.add("yjbhmjgjcd");
		rootNameChildList.add("土壤腐蚀性检测");
		rootNameChildList.add("杂散电流检测");
		//rootNameChildList.add("防腐层绝缘电阻");
		rootNameChildList.add("防腐层检测点");
		rootNameChildList.add("防腐层破损点");	
		rootNameChildList.add("测试桩检测");
		//rootNameChildList.add("阴极保护效果检测");
		rootNameChildList.add("阴极保护密间隔检测点");
		tablenameChildList.add("ptem_soilcorrosion");
		tablenameChildList.add("ptem_straycurrenttest");
		//tablenameChildList.add("ptem_straycurrenttest");
		tablenameChildList.add("ptem_risotest_pcm_testdata");
		tablenameChildList.add("ptem_coating_damagedpoint");
		tablenameChildList.add("ptem_testpileinspect");
		//tablenameChildList.add("ptem_cips_test_data");
		tablenameChildList.add("ptem_cips_test_data");
		
		fieldnameChildList.add("ID");
		fieldnameChildList.add("ID");
		fieldnameChildList.add("ID");
		fieldnameChildList.add("ID");
		fieldnameChildList.add("ID");
		fieldnameChildList.add("ID");
		
		fieldnameChildListDes.add("TESTPOINTNO");
		fieldnameChildListDes.add("STRAYPOINTNO");	
		fieldnameChildListDes.add("DATALOCATIONY,DATALOCATIONX");
		fieldnameChildListDes.add("DAMAGEPOINTNO");
		fieldnameChildListDes.add("TESTPILENO");
		fieldnameChildListDes.add("DATAY,DATAX");
		
		
		jsonArray=getNodesParent(pipeLineNO,nodetypes,"fshfhjc",
				"fshfhjcRoot","腐蚀防护系统检测",nodetypeChildList,rootNameChildList,
				tablenameChildList,fieldnameChildList,fieldnameChildListDes);
		return jsonArray;
	}
	public JSONArray getGuanxianTreeRootTypeGxChecked(String nodetypes) throws IOException{
		JSONArray jsonArray = new JSONArray();
		JSONObject guanxianroot = GenerateNode("guanxianroot","root","管线",true);
		jsonArray.add(guanxianroot);
		String pipelineno=getSession().getAttribute("pipelinenos").toString();
		//获得管线信息
		String pipelinenos[]=pipelineno.split(",");
		int pipelinenum=pipelinenos.length;		
		for(int i=0;i<pipelinenum;i++){
			String pipeLineNO=pipelinenos[i];
			String pId="guanxianroot";
			String nodeId="gx"+pipeLineNO;
			String nodeName=pipeLineNO;
			List<JSONArray> jsonArrayList=new ArrayList();
			JSONArray jsonArrayT= new JSONArray();
			//添加各管线节点
			JSONObject guanxian = GenerateNode(nodeId,pId,nodeName,true);
			jsonArray.add(guanxian);
			//添加管段根节点
			JSONObject guanduanroot = GenerateNode("gdroot"+pipeLineNO,"gx"+pipeLineNO,"管段",true);
			jsonArray.add(guanduanroot);			
			//管段
			jsonArrayT=getGuanDuanNode("gdroot"+pipeLineNO);
			jsonArrayList.add(jsonArrayT);	
			//阀门根节点
			JSONObject valveRoot = GenerateNode("valveRoot"+pipeLineNO,"gx"+pipeLineNO,"阀门",true);
			jsonArray.add(valveRoot);
			//阀门
			jsonArrayT=getValveNode("valveRoot"+pipeLineNO);
			jsonArrayList.add(jsonArrayT);	
			//特征点
			jsonArrayT=getNodesLeaf(pipeLineNO,nodetypes,"tezhengd","tzroot","特征点","PTEM_PIPEPOINT","POINTNO");					
			jsonArrayList.add(jsonArrayT);		
			//管件
			jsonArrayT=getGuanjianNode(pipeLineNO,nodetypes);
			jsonArrayList.add(jsonArrayT);	
			//穿跨越
			jsonArrayT=getNodesLeaf(pipeLineNO,nodetypes,"chuankuay",
					"chuankuayRoot","穿跨越","ptem_point_crossing","CROSSINGNO");					
			jsonArrayList.add(jsonArrayT);	
			//内衬
			jsonArrayT=getNodesLeaf(pipeLineNO,nodetypes,"neichen",
					"neichenRoot","内衬","ptem_point_liner","LINERNO");								
			jsonArrayList.add(jsonArrayT);
			//附属设施
			jsonArrayT=getFushusheshiNode(pipeLineNO,nodetypes);			
			jsonArrayList.add(jsonArrayT);	
			//生产运行
			jsonArrayT=getShengchanyunxingNode(pipeLineNO,nodetypes);
			jsonArrayList.add(jsonArrayT);
			//生产作业
			jsonArrayT=getShengchanzuoyeNode(pipeLineNO,nodetypes);
			jsonArrayList.add(jsonArrayT);
			//事件
			jsonArrayT=getShjianNode(pipeLineNO,nodetypes);
			jsonArrayList.add(jsonArrayT);
			//特征点检查
			jsonArrayT=getNodesLeaf(pipeLineNO,nodetypes,"testtzhdjch",
					"testtzhdjchRoot","特征点检查","ptem_point_test","POINTNO");								
			jsonArrayList.add(jsonArrayT);
			//穿越检查
			jsonArrayT=getNodesLeaf(pipeLineNO,nodetypes,"chyjch",
					"chyjchRoot","穿越检查","ptem_crossing_test","CROSSINGNO");								
			jsonArrayList.add(jsonArrayT);
			//直接检查
			jsonArrayT=getZhijiejianchaNode(pipeLineNO,nodetypes);
			jsonArrayList.add(jsonArrayT);
			//专项检测
			jsonArrayT=getZhuanxiangjianchaNode(pipeLineNO,nodetypes);
			jsonArrayList.add(jsonArrayT);
			//理化检测
			jsonArrayT=getLihuajianceNode(pipeLineNO,nodetypes);
			jsonArrayList.add(jsonArrayT);
			//泄漏检测
			jsonArrayT=getXieloujianceNode(pipeLineNO,nodetypes);
			jsonArrayList.add(jsonArrayT);
			//腐蚀防护系统检测
			jsonArrayT=getFushifanghuxitongjianceNode(pipeLineNO,nodetypes);
			jsonArrayList.add(jsonArrayT);
			//节点添加到JSonArray中
			int listnum=jsonArrayList.size();
			for(int k=0;k<listnum;k++)
			{
				jsonArrayT=jsonArrayList.get(k);
				int num=jsonArrayT.size();
				for(int j=0;j<num;j++)
				{
					JSONObject json=jsonArrayT.getJSONObject(j);
					jsonArray.add(json);
				}
			}
		}
		//站箱
		JSONObject zhanxiangroot = GenerateNode("zhanxiangroot","root","站箱",true);
		jsonArray.add(zhanxiangroot);	
		//获得站箱信息
		//strSql = "select t.id,t.stationname from ptem_station t";
		String strSql = "select t.PIPENO,t.stationname,t.stationno from ptem_station t";
		List zhanxianglists = dbService.queryDataBySql(strSql);
		for(int i=0;i<zhanxianglists.size();i++){
			Object[] objs = (Object[])zhanxianglists.get(i);
			String pipeno=objs[0].toString();
			String zhanxiangName=objs[1].toString();
			String stationno=objs[2].toString();
			//JSONObject zhanxiang = GenerateNode("zx"+pipeno,"zhanxiangroot",zhanxiangName,true);
			JSONObject zhanxiang = GenerateNode("zx"+stationno,"zhanxiangroot",zhanxiangName,true);			
			jsonArray.add(zhanxiang);
			//过滤器
			String sql="select t.LOCATIONNO from ptem_filter t where t.PIPENETNO='";
			sql+=pipeno;
			sql+="'";
			List<String> list=dbService.queryDataBySql(sql);
			int numglq=list.size();
			JSONObject jsonRoot = GenerateNode("glqRoot"+pipeno,"zx"+pipeno,"过滤器",true);
			jsonArray.add(jsonRoot);
			for(int j=0;j<numglq;j++)
			{
				String locationno=list.get(j);
				JSONObject json = GenerateNode("glq"+locationno,"glqRoot"+pipeno,locationno,false);
				jsonArray.add(json);
			}
			//安全阀
			sql="select t.SAFETYVALVENO from ptem_safetyvalve t where t.PIPENETNO='";
			sql+=pipeno;
			sql+="'";
			list=dbService.queryDataBySql(sql);
			int num=list.size();
			jsonRoot = GenerateNode("aqfRoot"+pipeno,"zx"+pipeno,"安全阀",true);
			jsonArray.add(jsonRoot);
			for(int j=0;j<num;j++)
			{
				String safetyvalveno=list.get(j);
				JSONObject json = GenerateNode("aqf"+safetyvalveno,"aqfRoot"+pipeno,safetyvalveno,false);
				jsonArray.add(json);
			}
		}
		return jsonArray;
	}
	//点击根节点时调用
	public JSONArray getGuanxianTreeRootType(String nodetypes) throws IOException{
		JSONArray jsonArray = new JSONArray();
		JSONObject guanxianroot = GenerateNode("guanxianroot","root","管线",true);
		jsonArray.add(guanxianroot);
		String pipelineno=getSession().getAttribute("pipelinenos").toString();
		//获得管线信息
		String pipelinenos[]=pipelineno.split(",");
		int pipelinenum=pipelinenos.length;
		for(int i=0;i<pipelinenum;i++){
			String pipeLineNO=pipelinenos[i];
			String pId="guanxianroot";
			String nodeId="gx"+pipeLineNO;
			String nodeName=pipeLineNO;
			//添加各管线节点
			JSONObject guanxian = GenerateNode(nodeId,pId,nodeName,true);
			jsonArray.add(guanxian);
			//添加管段根节点
			JSONObject guanduanroot = GenerateNode("gdroot"+pipeLineNO,"gx"+pipeLineNO,"管段",true);
			jsonArray.add(guanduanroot);
			//阀门根节点
			JSONObject valveRoot = GenerateNode("valveRoot"+pipeLineNO,"gx"+pipeLineNO,"阀门",true);
			jsonArray.add(valveRoot);
			//特征点
			if (nodetypes.indexOf("tezhengd")>=0){
				JSONObject tezhengdroot = GenerateNode("tzroot"+pipeLineNO,"gx"+pipeLineNO,"特征点",true);
				jsonArray.add(tezhengdroot);
			}
			//管件
			if (nodetypes.indexOf("guanjian")>=0){
				JSONObject root = GenerateNode("gjroot"+pipeLineNO,"gx"+pipeLineNO,"管件",true);
				jsonArray.add(root);
				//三通
				JSONObject santongdroot = GenerateNode("pointTeeRoot"+pipeLineNO,"gjroot"+pipeLineNO,"三通",true);
				jsonArray.add(santongdroot);
				//套管
				JSONObject taoguanroot = GenerateNode("taoguanRoot"+pipeLineNO,"gjroot"+pipeLineNO,"套管",true);
				jsonArray.add(taoguanroot);
				//弯管
				JSONObject wanguanroot = GenerateNode("wanguanRoot"+pipeLineNO,"gjroot"+pipeLineNO,"弯管",true);
				jsonArray.add(wanguanroot);
			}
			if (nodetypes.indexOf("guanjian")<0){
				//勾选了三通、套管或弯管
				if(nodetypes.indexOf("pointTee")>=0
						||nodetypes.indexOf("taoguan")>=0
						||nodetypes.indexOf("wanguan")>=0)
				{
					JSONObject root = GenerateNode("gjroot"+pipeLineNO,"gx"+pipeLineNO,"管件",true);
					jsonArray.add(root);
				}
				//显示三通
				if (nodetypes.indexOf("pointTee")>=0){
					JSONObject santongdroot = GenerateNode("pointTeeRoot"+pipeLineNO,"gjroot"+pipeLineNO,"三通",true);
					jsonArray.add(santongdroot);
				}
				//显示套管
				if (nodetypes.indexOf("taoguan")>=0){
					JSONObject santongdroot = GenerateNode("taoguanRoot"+pipeLineNO,"gjroot"+pipeLineNO,"套管",true);
					jsonArray.add(santongdroot);
				}
				//显示弯管
				if (nodetypes.indexOf("wanguan")>=0){
					JSONObject santongdroot = GenerateNode("wanguanRoot"+pipeLineNO,"gjroot"+pipeLineNO,"弯管",true);
					jsonArray.add(santongdroot);
				}
			}	
			//穿跨越
			if (nodetypes.indexOf("chuankuay")>=0){
				JSONObject root = GenerateNode("chuankuayRoot"+pipeLineNO,"gx"+pipeLineNO,"穿跨越",true);
				jsonArray.add(root);
			}
			//内衬
			if (nodetypes.indexOf("neichen")>=0){
				JSONObject tezhengdroot = GenerateNode("neichenRoot"+pipeLineNO,"gx"+pipeLineNO,"内衬",true);
				jsonArray.add(tezhengdroot);
			}
			
			//附属设施
			if (nodetypes.indexOf("fushuss")>=0){
				JSONObject root = GenerateNode("fsssroot"+pipeLineNO,"gx"+pipeLineNO,"附属设施",true);
				jsonArray.add(root);
				//阳极
				JSONObject yangjiroot = GenerateNode("pointAnodeRoot"+pipeLineNO,"fsssroot"+pipeLineNO,"阳极",true);
				jsonArray.add(yangjiroot);
				//测试桩
				JSONObject ceshizhuangroot = GenerateNode("pointPoleRoot"+pipeLineNO,"fsssroot"+pipeLineNO,"测试桩",true);
				jsonArray.add(ceshizhuangroot);
				//排流装置
				JSONObject pailiuzhuangzhiroot = GenerateNode("pointDrainageRoot"+pipeLineNO,"fsssroot"+pipeLineNO,"排流装置",true);
				jsonArray.add(pailiuzhuangzhiroot);
			}
			if(nodetypes.indexOf("fushuss")<0){
				if(nodetypes.indexOf("pointAnode")>=0||
				   nodetypes.indexOf("pointPole")>=0||
				   nodetypes.indexOf("pointDrainage")>=0
				   )
				{
					JSONObject root = GenerateNode("fsssroot"+pipeLineNO,"gx"+pipeLineNO,"附属设施",true);
					jsonArray.add(root);
					//阳极
					if (nodetypes.indexOf("pointAnode")>=0){
						JSONObject yangjiroot = GenerateNode("pointAnodeRoot"+pipeLineNO,"fsssroot"+pipeLineNO,"阳极",true);
						jsonArray.add(yangjiroot);	
					}			
					//显示测试桩
					if (nodetypes.indexOf("pointPole")>=0){
						JSONObject ceshizhuangroot = GenerateNode("pointPoleRoot"+pipeLineNO,"fsssroot"+pipeLineNO,"测试桩",true);
						jsonArray.add(ceshizhuangroot);
					}
					//排流装置
					if (nodetypes.indexOf("pointDrainage")>=0){
						JSONObject pailiuzhuangzhiroot = GenerateNode("pointDrainageRoot"+pipeLineNO,"fsssroot"+pipeLineNO,"排流装置",true);
						jsonArray.add(pailiuzhuangzhiroot);
					}
				}
			}
			//生产运行
			if (nodetypes.indexOf("shchyx")>=0){
				JSONObject root = GenerateNode("shchyxRoot"+pipeLineNO,"gx"+pipeLineNO,"生产运行",true);
				jsonArray.add(root);
				//异常
				JSONObject yichangroot = GenerateNode("yichangRoot"+pipeLineNO,"shchyxRoot"+pipeLineNO,"异常",true);
				jsonArray.add(yichangroot);
				//特殊段
				JSONObject teshuduanroot = GenerateNode("teshuduanRoot"+pipeLineNO,"shchyxRoot"+pipeLineNO,"特殊段",true);
				jsonArray.add(teshuduanroot);
				//违章占压
				JSONObject wzzyroot = GenerateNode("wzzyRoot"+pipeLineNO,"shchyxRoot"+pipeLineNO,"违章占压",true);
				jsonArray.add(wzzyroot);
			}
			if(nodetypes.indexOf("shchyx")<0){
				if(nodetypes.indexOf("yichang")>=0||
				   nodetypes.indexOf("teshuduan")>=0||
				   nodetypes.indexOf("wzzy")>=0
				   )
				{
					JSONObject root = GenerateNode("shchyxRoot"+pipeLineNO,"gx"+pipeLineNO,"生产运行",true);
					jsonArray.add(root);
					//异常
					if (nodetypes.indexOf("yichang")>=0){
						JSONObject yichangroot = GenerateNode("yichangRoot"+pipeLineNO,"shchyxRoot"+pipeLineNO,"异常",true);
						jsonArray.add(yichangroot);
					}			
					//特殊段
					if (nodetypes.indexOf("teshuduan")>=0){
						JSONObject teshuduanroot = GenerateNode("teshuduanRoot"+pipeLineNO,"shchyxRoot"+pipeLineNO,"特殊段",true);
						jsonArray.add(teshuduanroot);
					}
					//违章占压
					if (nodetypes.indexOf("wzzy")>=0){
						JSONObject wzzyroot = GenerateNode("wzzyRoot"+pipeLineNO,"shchyxRoot"+pipeLineNO,"违章占压",true);
						jsonArray.add(wzzyroot);
					}
				}
			}
			//生产作业
			if (nodetypes.indexOf("shchzy")>=0){
				JSONObject root = GenerateNode("shchzyRoot"+pipeLineNO,"gx"+pipeLineNO,"生产作业",true);
				jsonArray.add(root);
				//生产作业点
				JSONObject child1 = GenerateNode("shengchanzydRoot"+pipeLineNO,"shchzyRoot"+pipeLineNO,"生产作业点",true);
				jsonArray.add(child1);
				//带气作业机械预制件
				JSONObject child2 = GenerateNode("dqzyjxyzhRoot"+pipeLineNO,"shchzyRoot"+pipeLineNO,"带气作业机械预制件",true);
				jsonArray.add(child2);
			}
			if(nodetypes.indexOf("shchzy")<0){
				if(nodetypes.indexOf("shengchanzyd")>=0||
				   nodetypes.indexOf("dqzyjxyzh")>=0
				   )
				{
					JSONObject root = GenerateNode("shchzyRoot"+pipeLineNO,"gx"+pipeLineNO,"生产作业",true);
					jsonArray.add(root);
					//生产作业点
					if (nodetypes.indexOf("shengchanzyd")>=0){
						JSONObject child1 = GenerateNode("shengchanzydRoot"+pipeLineNO,"shchzyRoot"+pipeLineNO,"生产作业点",true);
						jsonArray.add(child1);
					}			
					//带气作业机械预制件
					if (nodetypes.indexOf("dqzyjxyzh")>=0){
						JSONObject child2 = GenerateNode("dqzyjxyzhRoot"+pipeLineNO,"shchzyRoot"+pipeLineNO,"带气作业机械预制件",true);
						jsonArray.add(child2);
					}
				}
			}
			//事件
			if (nodetypes.indexOf("shijian")>=0){
				JSONObject root = GenerateNode("shijianRoot"+pipeLineNO,"gx"+pipeLineNO,"事件",true);
				jsonArray.add(root);
				
				JSONObject child1 = GenerateNode("sjdRoot"+pipeLineNO,"shijianRoot"+pipeLineNO,"事件点",true);
				jsonArray.add(child1);
				
				JSONObject child2 = GenerateNode("xldRoot"+pipeLineNO,"shijianRoot"+pipeLineNO,"泄漏点",true);
				jsonArray.add(child2);
			}
			if(nodetypes.indexOf("shijian")<0){
				if(nodetypes.indexOf("sjd")>=0||
				   nodetypes.indexOf("xld")>=0
				   )
				{
					JSONObject root = GenerateNode("shijianRoot"+pipeLineNO,"gx"+pipeLineNO,"事件",true);
					jsonArray.add(root);
					
					if (nodetypes.indexOf("sjd")>=0){
						JSONObject child1 = GenerateNode("sjdRoot"+pipeLineNO,"shijianRoot"+pipeLineNO,"事件点",true);
						jsonArray.add(child1);
					}			
					
					if (nodetypes.indexOf("xld")>=0){
						JSONObject child2 = GenerateNode("xldRoot"+pipeLineNO,"shijianRoot"+pipeLineNO,"泄漏点",true);
						jsonArray.add(child2);
					}
				}
			}
			//特征点检查
			if (nodetypes.indexOf("testtzhdjch")>=0){
				JSONObject root = GenerateNode("testtzhdjchRoot"+pipeLineNO,"gx"+pipeLineNO,"特征点检查",true);
				jsonArray.add(root);
			}
			//穿越检查
			if (nodetypes.indexOf("chyjch")>=0){
				JSONObject root = GenerateNode("chyjchRoot"+pipeLineNO,"gx"+pipeLineNO,"穿越检查",true);
				jsonArray.add(root);
			}
			//直接检查
			if (nodetypes.indexOf("zhjjch")>=0){
				JSONObject root = GenerateNode("zhjjchRoot"+pipeLineNO,"gx"+pipeLineNO,"直接检查",true);
				jsonArray.add(root);
			
				JSONObject child1 = GenerateNode("wgjchRoot"+pipeLineNO,"zhjjchRoot"+pipeLineNO,"外观检查",true);
				jsonArray.add(child1);

				JSONObject child2 = GenerateNode("bhjcRoot"+pipeLineNO,"zhjjchRoot"+pipeLineNO,"壁厚检测",true);
				jsonArray.add(child2);
				
				JSONObject child3 = GenerateNode("ffchdjcRoot"+pipeLineNO,"zhjjchRoot"+pipeLineNO,"防腐层厚度检测",true);
				jsonArray.add(child3);
				
				JSONObject child4 = GenerateNode("ffcpsjcRoot"+pipeLineNO,"zhjjchRoot"+pipeLineNO,"防腐层破损检测",true);
				jsonArray.add(child4);
				
				JSONObject child5 = GenerateNode("fshzhkjcRoot"+pipeLineNO,"zhjjchRoot"+pipeLineNO,"腐蚀状况检测",true);
				jsonArray.add(child5);
				
				JSONObject child6 = GenerateNode("shexianjcRoot"+pipeLineNO,"zhjjchRoot"+pipeLineNO,"射线检测",true);
				jsonArray.add(child6);
			}
			if(nodetypes.indexOf("zhjjch")<0){
				if(nodetypes.indexOf("wgjch")>=0||
				   nodetypes.indexOf("bhjc")>=0||
				   nodetypes.indexOf("ffchdjc")>=0||
				   nodetypes.indexOf("ffcpsjc")>=0||
				   nodetypes.indexOf("fshzhkjc")>=0||
				   nodetypes.indexOf("shexianjc")>=0
				   )
				{
					JSONObject root = GenerateNode("zhjjchRoot"+pipeLineNO,"gx"+pipeLineNO,"直接检查",true);
					jsonArray.add(root);
					
					if (nodetypes.indexOf("wgjch")>=0){
						JSONObject child1 = GenerateNode("wgjchRoot"+pipeLineNO,"zhjjchRoot"+pipeLineNO,"外观检查",true);
						jsonArray.add(child1);
					}			
					
					if (nodetypes.indexOf("bhjc")>=0){
						JSONObject child2 = GenerateNode("bhjcRoot"+pipeLineNO,"zhjjchRoot"+pipeLineNO,"壁厚检测",true);
						jsonArray.add(child2);
					}
					
					if (nodetypes.indexOf("ffchdjc")>=0){
						JSONObject child3 = GenerateNode("ffchdjcRoot"+pipeLineNO,"zhjjchRoot"+pipeLineNO,"防腐层厚度检测",true);
						jsonArray.add(child3);
					}
					
					if (nodetypes.indexOf("ffcpsjc")>=0){
						JSONObject child4 = GenerateNode("ffcpsjcRoot"+pipeLineNO,"zhjjchRoot"+pipeLineNO,"防腐层破损检测",true);
						jsonArray.add(child4);
					}
					
					if (nodetypes.indexOf("fshzhkjc")>=0){
						JSONObject child5 = GenerateNode("fshzhkjcRoot"+pipeLineNO,"zhjjchRoot"+pipeLineNO,"腐蚀状况检测",true);
						jsonArray.add(child5);
					}
					
					if (nodetypes.indexOf("shexianjc")>=0){
						JSONObject child6 = GenerateNode("shexianjcRoot"+pipeLineNO,"zhjjchRoot"+pipeLineNO,"射线检测",true);
						jsonArray.add(child6);
					}
				}
			}
			//专项检测
			if (nodetypes.indexOf("zhxjc")>=0){
				JSONObject root = GenerateNode("zhxjcRoot"+pipeLineNO,"gx"+pipeLineNO,"专项检测",true);
				jsonArray.add(root);
				
				JSONObject child1= GenerateNode("dbjcRoot"+pipeLineNO,"zhxjcRoot"+pipeLineNO,"导波检测",true);
				jsonArray.add(child1);
				
				JSONObject child2 = GenerateNode("cjyjcRoot"+pipeLineNO,"zhxjcRoot"+pipeLineNO,"磁记忆检测",true);
				jsonArray.add(child2);
				
				JSONObject child3 = GenerateNode("shbdcjcRoot"+pipeLineNO,"zhxjcRoot"+pipeLineNO,"瞬变电磁检测",true);
				jsonArray.add(child3);
			}
			if(nodetypes.indexOf("zhxjc")<0){
				if(nodetypes.indexOf("dbjc")>=0||
				   nodetypes.indexOf("cjyjc")>=0||
				   nodetypes.indexOf("shbdcjc")>=0
				   )
				{				
					JSONObject root = GenerateNode("zhxjcRoot"+pipeLineNO,"gx"+pipeLineNO,"专项检测",true);
					jsonArray.add(root);
					
					if (nodetypes.indexOf("dbjc")>=0){
						JSONObject child1= GenerateNode("dbjcRoot"+pipeLineNO,"zhxjcRoot"+pipeLineNO,"导波检测",true);
						jsonArray.add(child1);
					}			
					
					if (nodetypes.indexOf("cjyjc")>=0){
						JSONObject child2 = GenerateNode("cjyjcRoot"+pipeLineNO,"zhxjcRoot"+pipeLineNO,"磁记忆检测",true);
						jsonArray.add(child2);
					}
					
					if (nodetypes.indexOf("shbdcjc")>=0){
						JSONObject child3 = GenerateNode("shbdcjcRoot"+pipeLineNO,"zhxjcRoot"+pipeLineNO,"瞬变电磁检测",true);
						jsonArray.add(child3);
					}
				}
			}
			//理化检测
			if (nodetypes.indexOf("lhjc")>=0){
				JSONObject root = GenerateNode("lhjcRoot"+pipeLineNO,"gx"+pipeLineNO,"理化检测",true);
				jsonArray.add(root);
				
				JSONObject child1= GenerateNode("ylshyRoot"+pipeLineNO,"lhjcRoot"+pipeLineNO,"应力试验",true);
				jsonArray.add(child1);
				
				JSONObject child2 = GenerateNode("hxchffxRoot"+pipeLineNO,"lhjcRoot"+pipeLineNO,"化学成分分析",true);
				jsonArray.add(child2);
				
				JSONObject child3 = GenerateNode("ydcshRoot"+pipeLineNO,"lhjcRoot"+pipeLineNO,"硬度测试",true);
				jsonArray.add(child3);
				
				JSONObject child4 = GenerateNode("jxfxRoot"+pipeLineNO,"lhjcRoot"+pipeLineNO,"金相分析",true);
				jsonArray.add(child4);
				
				JSONObject child5 = GenerateNode("lshshyRoot"+pipeLineNO,"lhjcRoot"+pipeLineNO,"拉伸试验",true);
				jsonArray.add(child5);
				
				JSONObject child6 = GenerateNode("wqshiyRoot"+pipeLineNO,"lhjcRoot"+pipeLineNO,"弯曲试验",true);
				jsonArray.add(child6);
				
				JSONObject child7 = GenerateNode("chjshyRoot"+pipeLineNO,"lhjcRoot"+pipeLineNO,"冲击试验",true);
				jsonArray.add(child7);
			}
			if(nodetypes.indexOf("lhjc")<0){
				if(nodetypes.indexOf("ylshy")>=0||
				   nodetypes.indexOf("hxchffx")>=0||
				   nodetypes.indexOf("ydcsh")>=0||
				   nodetypes.indexOf("jxfx")>=0||
				   nodetypes.indexOf("lshshy")>=0||
				   nodetypes.indexOf("wqshiy")>=0||
				   nodetypes.indexOf("chjshy")>=0
				   )
				{				
					JSONObject root = GenerateNode("lhjcRoot"+pipeLineNO,"gx"+pipeLineNO,"理化检测",true);
					jsonArray.add(root);
					
					if (nodetypes.indexOf("ylshy")>=0){
						JSONObject child1= GenerateNode("ylshyRoot"+pipeLineNO,"lhjcRoot"+pipeLineNO,"应力试验",true);
						jsonArray.add(child1);
					}			
					
					if (nodetypes.indexOf("hxchffx")>=0){
						JSONObject child2 = GenerateNode("hxchffxRoot"+pipeLineNO,"lhjcRoot"+pipeLineNO,"化学成分分析",true);
						jsonArray.add(child2);
					}
					
					if (nodetypes.indexOf("ydcsh")>=0){
						JSONObject child3 = GenerateNode("ydcshRoot"+pipeLineNO,"lhjcRoot"+pipeLineNO,"硬度测试",true);
						jsonArray.add(child3);
					}
					
					if (nodetypes.indexOf("jxfx")>=0){
						JSONObject child4 = GenerateNode("jxfxRoot"+pipeLineNO,"lhjcRoot"+pipeLineNO,"金相分析",true);
						jsonArray.add(child4);
					}
					
					if (nodetypes.indexOf("lshshy")>=0){
						JSONObject child5 = GenerateNode("lshshyRoot"+pipeLineNO,"lhjcRoot"+pipeLineNO,"拉伸试验",true);
						jsonArray.add(child5);
					}
					
					if (nodetypes.indexOf("wqshiy")>=0){
						JSONObject child6 = GenerateNode("wqshiyRoot"+pipeLineNO,"lhjcRoot"+pipeLineNO,"弯曲试验",true);
						jsonArray.add(child6);
					}
					
					if (nodetypes.indexOf("chjshy")>=0){
						JSONObject child7 = GenerateNode("chjshyRoot"+pipeLineNO,"lhjcRoot"+pipeLineNO,"冲击试验",true);
						jsonArray.add(child7);
					}
				}
			}
			//泄漏检测
			if (nodetypes.indexOf("xljc")>=0){
				JSONObject root = GenerateNode("xljcRoot"+pipeLineNO,"gx"+pipeLineNO,"泄漏检测",true);
				jsonArray.add(root);
				JSONObject child1 = GenerateNode("xljcjcdRoot"+pipeLineNO,"xljcRoot"+pipeLineNO,"检测点",true);
				jsonArray.add(child1);
				JSONObject child2 = GenerateNode("xljcxldRoot"+pipeLineNO,"xljcRoot"+pipeLineNO,"泄漏点",true);
				jsonArray.add(child2);
			}
			if(nodetypes.indexOf("xljc")<0){
				if(nodetypes.indexOf("xljcjcd")>=0||
				   nodetypes.indexOf("xljcxld")>=0
				   )
				{
					JSONObject root = GenerateNode("xljcRoot"+pipeLineNO,"gx"+pipeLineNO,"泄漏检测",true);
					jsonArray.add(root);
					if (nodetypes.indexOf("xljcjcd")>=0){
						JSONObject child1 = GenerateNode("xljcjcdRoot"+pipeLineNO,"xljcRoot"+pipeLineNO,"检测点",true);
						jsonArray.add(child1);
					}			
					if (nodetypes.indexOf("xljcxld")>=0){
						JSONObject child2 = GenerateNode("xljcxldRoot"+pipeLineNO,"xljcRoot"+pipeLineNO,"泄漏点",true);
						jsonArray.add(child2);
					}
				}
			}
			//腐蚀防护系统检测
			if (nodetypes.indexOf("fshfhjc")>=0){
				JSONObject root = GenerateNode("fshfhjcRoot"+pipeLineNO,"gx"+pipeLineNO,"腐蚀防护系统检测",true);
				jsonArray.add(root);
				JSONObject child1 = GenerateNode("trfshxjcRoot"+pipeLineNO,"fshfhjcRoot"+pipeLineNO,"土壤腐蚀性检测",true);
				jsonArray.add(child1);
				JSONObject child2 = GenerateNode("zsdljcRoot"+pipeLineNO,"fshfhjcRoot"+pipeLineNO,"杂散电流检测",true);
				jsonArray.add(child2);
				JSONObject child3 = GenerateNode("ffcjydzRoot"+pipeLineNO,"fshfhjcRoot"+pipeLineNO,"防腐层绝缘电阻",true);
				jsonArray.add(child3);
				JSONObject child4 = GenerateNode("ffcjcdRoot"+pipeLineNO,"fshfhjcRoot"+pipeLineNO,"防腐层检测点",true);
				jsonArray.add(child4);
				JSONObject child5 = GenerateNode("ffcpsdRoot"+pipeLineNO,"fshfhjcRoot"+pipeLineNO,"防腐层破损点",true);
				jsonArray.add(child5);
				JSONObject child6 = GenerateNode("cshzhjcRoot"+pipeLineNO,"fshfhjcRoot"+pipeLineNO,"测试桩检测",true);
				jsonArray.add(child6);
				JSONObject child7= GenerateNode("yjbhxgjcRoot"+pipeLineNO,"fshfhjcRoot"+pipeLineNO,"阴极保护效果检测",true);
				jsonArray.add(child7);
				JSONObject child8= GenerateNode("yjbhmjgjcdRoot"+pipeLineNO,"fshfhjcRoot"+pipeLineNO,"阴极保护密间隔检测点",true);
				jsonArray.add(child8);
			}
			if(nodetypes.indexOf("fshfhjc")<0){
				if(nodetypes.indexOf("trfshxjc")>=0||
				   nodetypes.indexOf("zsdljc")>=0||
				   nodetypes.indexOf("ffcjydz")>=0||
				   nodetypes.indexOf("ffcjcd")>=0||
				   nodetypes.indexOf("ffcpsd")>=0||
				   nodetypes.indexOf("cshzhjc")>=0||
				   nodetypes.indexOf("yjbhxgjc")>=0||
				   nodetypes.indexOf("yjbhmjgjcd")>=0
				   )
				{
					JSONObject root = GenerateNode("fshfhjcRoot"+pipeLineNO,"gx"+pipeLineNO,"腐蚀防护系统检测",true);
					jsonArray.add(root);
					if (nodetypes.indexOf("trfshxjc")>=0){
						JSONObject child1 = GenerateNode("trfshxjcRoot"+pipeLineNO,"fshfhjcRoot"+pipeLineNO,"土壤腐蚀性检测",true);
						jsonArray.add(child1);
					}			
					if (nodetypes.indexOf("zsdljc")>=0){
						JSONObject child2 = GenerateNode("zsdljcRoot"+pipeLineNO,"fshfhjcRoot"+pipeLineNO,"杂散电流检测",true);
						jsonArray.add(child2);
					}
					if (nodetypes.indexOf("ffcjydz")>=0){
						JSONObject child3 = GenerateNode("ffcjydzRoot"+pipeLineNO,"fshfhjcRoot"+pipeLineNO,"防腐层绝缘电阻",true);
						jsonArray.add(child3);
					}
					if (nodetypes.indexOf("ffcjcd")>=0){
						JSONObject child4 = GenerateNode("ffcjcdRoot"+pipeLineNO,"fshfhjcRoot"+pipeLineNO,"防腐层检测点",true);
						jsonArray.add(child4);
					}
					if (nodetypes.indexOf("ffcpsd")>=0){
						JSONObject child5 = GenerateNode("ffcpsdRoot"+pipeLineNO,"fshfhjcRoot"+pipeLineNO,"防腐层破损点",true);
						jsonArray.add(child5);
					}			
					if (nodetypes.indexOf("cshzhjc")>=0){
						JSONObject child6 = GenerateNode("cshzhjcRoot"+pipeLineNO,"fshfhjcRoot"+pipeLineNO,"测试桩检测",true);
						jsonArray.add(child6);
					}
					if (nodetypes.indexOf("yjbhxgjc")>=0){
						JSONObject child7= GenerateNode("yjbhxgjcRoot"+pipeLineNO,"fshfhjcRoot"+pipeLineNO,"阴极保护效果检测",true);
						jsonArray.add(child7);
					}
					if (nodetypes.indexOf("yjbhmjgjcd")>=0){
						JSONObject child8= GenerateNode("yjbhmjgjcdRoot"+pipeLineNO,"fshfhjcRoot"+pipeLineNO,"阴极保护密间隔检测点",true);
						jsonArray.add(child8);
					}
				}
			}
			//显示导波检测
//			if (nodetypes.indexOf("dbjc")>=0){
//				JSONObject root = GenerateNode("jcshujuRoot"+pipeLineNO,"gx"+pipeLineNO,"检测数据",true);
//				jsonArray.add(root);					
//				root = GenerateNode("dbjcRoot"+pipeLineNO,"jcshujuRoot"+pipeLineNO,"导波检测",true);
//				jsonArray.add(root);
//			}
		}
		//站箱
		JSONObject zhanxiangroot = GenerateNode("zhanxiangroot","root","站箱",true);
		jsonArray.add(zhanxiangroot);	
		//获得站箱信息
		//strSql = "select t.id,t.stationname from ptem_station t";
		String strSql = "select t.PIPENO,t.stationname from ptem_station t";
		List zhanxianglists = dbService.queryDataBySql(strSql);
		for(int i=0;i<zhanxianglists.size();i++){
			Object[] objs = (Object[])zhanxianglists.get(i);
			String pipeno=objs[0].toString();
			String zhanxiangName=objs[1].toString();
			JSONObject zhanxiang = GenerateNode("zx"+pipeno,"zhanxiangroot",zhanxiangName,true);
			jsonArray.add(zhanxiang);
			//过滤器
			String sql="select t.LOCATIONNO from ptem_filter t where t.PIPENETNO='";
			sql+=pipeno;
			sql+="'";
			List<String> list=dbService.queryDataBySql(sql);
			int num=list.size();
			JSONObject jsonRoot = GenerateNode("glqRoot"+pipeno,"zx"+pipeno,"过滤器",true);
			jsonArray.add(jsonRoot);
			for(int j=0;j<num;j++)
			{
				String locationno=list.get(j);
				JSONObject json = GenerateNode("glq"+locationno,"glqRoot"+pipeno,locationno,false);
				jsonArray.add(json);
			}
			//安全阀
			sql="select t.SAFETYVALVENO from ptem_safetyvalve t where t.PIPENETNO='";
			sql+=pipeno;
			sql+="'";
			list=dbService.queryDataBySql(sql);
			num=list.size();
			jsonRoot = GenerateNode("aqfRoot"+pipeno,"zx"+pipeno,"安全阀",true);
			jsonArray.add(jsonRoot);
			for(int j=0;j<num;j++)
			{
				String safetyvalveno=list.get(j);
				JSONObject json = GenerateNode("aqf"+safetyvalveno,"aqfRoot"+pipeno,safetyvalveno,false);
				jsonArray.add(json);
			}
		}
		return jsonArray;
	}
	
	//点击根节点时调用
	public JSONArray getGuanxianTreeRoot(String nodetypes) throws IOException{
		JSONArray jsonArray = new JSONArray();
		//JSONObject guanxianroot = GenerateNode("guanxianrootAll","root","管线",true);		
		JSONObject guanxianroot = GenerateNode("guanxianroot","root","管线",true);
		jsonArray.add(guanxianroot);
		String pipelinenos="";
		//获得管线信息
		String strSql = "select t.pipelineno from ptem_pipeline t";
		List guanxianlists = dbService.queryDataBySql(strSql);
		for(int i=0;i<guanxianlists.size();i++){
			String pipeLineNO=guanxianlists.get(i).toString();
			String pId="guanxianroot";
			//String pId="guanxianrootAll";
			String nodeId="gx"+pipeLineNO;
			String nodeName=guanxianlists.get(i).toString();
			pipelinenos+=nodeName+",";			
			//添加各管线节点
			JSONObject guanxian = GenerateNode(nodeId,pId,nodeName,true);
			jsonArray.add(guanxian);
			//添加管段根节点
			JSONObject guanduanroot = GenerateNode("gdroot"+pipeLineNO,"gx"+pipeLineNO,"管段",true);
			jsonArray.add(guanduanroot);
			//阀门根节点
			JSONObject valveRoot = GenerateNode("valveRoot"+pipeLineNO,"gx"+pipeLineNO,"阀门",true);
			jsonArray.add(valveRoot);
			JSONArray jsonArray1=getValveNode("valveRoot"+pipeLineNO);	
			for(int j=0;j<jsonArray1.size();j++){
				jsonArray.add(jsonArray1.get(j));
			}
			//特征点
			if (nodetypes.indexOf("tezhengd")>=0){
				JSONObject tezhengdroot = GenerateNode("tzroot"+pipeLineNO,"gx"+pipeLineNO,"特征点",true);
				jsonArray.add(tezhengdroot);
			}
			//管件
			if (nodetypes.indexOf("guanjian")>=0){
				JSONObject root = GenerateNode("gjroot"+pipeLineNO,"gx"+pipeLineNO,"管件",true);
				jsonArray.add(root);
				//三通
				JSONObject santongdroot = GenerateNode("pointTeeRoot"+pipeLineNO,"gjroot"+pipeLineNO,"三通",true);
				jsonArray.add(santongdroot);
				//套管
				JSONObject taoguanroot = GenerateNode("taoguanRoot"+pipeLineNO,"gjroot"+pipeLineNO,"套管",true);
				jsonArray.add(taoguanroot);
				//弯管
				JSONObject wanguanroot = GenerateNode("wanguanRoot"+pipeLineNO,"gjroot"+pipeLineNO,"弯管",true);
				jsonArray.add(wanguanroot);
			}
			if (nodetypes.indexOf("guanjian")<0){
				//勾选了三通、套管或弯管
				if(nodetypes.indexOf("pointTee")>=0
						||nodetypes.indexOf("taoguan")>=0
						||nodetypes.indexOf("wanguan")>=0)
				{
					JSONObject root = GenerateNode("gjroot"+pipeLineNO,"gx"+pipeLineNO,"管件",true);
					jsonArray.add(root);
				}
				//显示三通
				if (nodetypes.indexOf("pointTee")>=0){
					JSONObject santongdroot = GenerateNode("pointTeeRoot"+pipeLineNO,"gjroot"+pipeLineNO,"三通",true);
					jsonArray.add(santongdroot);
				}
				//显示套管
				if (nodetypes.indexOf("taoguan")>=0){
					JSONObject santongdroot = GenerateNode("taoguanRoot"+pipeLineNO,"gjroot"+pipeLineNO,"套管",true);
					jsonArray.add(santongdroot);
				}
				//显示弯管
				if (nodetypes.indexOf("wanguan")>=0){
					JSONObject santongdroot = GenerateNode("wanguanRoot"+pipeLineNO,"gjroot"+pipeLineNO,"弯管",true);
					jsonArray.add(santongdroot);
				}
			}	
			//穿跨越
			if (nodetypes.indexOf("chuankuay")>=0){
				JSONObject root = GenerateNode("chuankuayRoot"+pipeLineNO,"gx"+pipeLineNO,"穿跨越",true);
				jsonArray.add(root);
			}
			//内衬
			if (nodetypes.indexOf("neichen")>=0){
				JSONObject tezhengdroot = GenerateNode("neichenRoot"+pipeLineNO,"gx"+pipeLineNO,"内衬",true);
				jsonArray.add(tezhengdroot);
			}
			
			//附属设施
			if (nodetypes.indexOf("fushuss")>=0){
				JSONObject root = GenerateNode("fsssroot"+pipeLineNO,"gx"+pipeLineNO,"附属设施",true);
				jsonArray.add(root);
				//阳极
				JSONObject yangjiroot = GenerateNode("pointAnodeRoot"+pipeLineNO,"fsssroot"+pipeLineNO,"阳极",true);
				jsonArray.add(yangjiroot);
				//测试桩
				JSONObject ceshizhuangroot = GenerateNode("pointPoleRoot"+pipeLineNO,"fsssroot"+pipeLineNO,"测试桩",true);
				jsonArray.add(ceshizhuangroot);
				//排流装置
				JSONObject pailiuzhuangzhiroot = GenerateNode("pointDrainageRoot"+pipeLineNO,"fsssroot"+pipeLineNO,"排流装置",true);
				jsonArray.add(pailiuzhuangzhiroot);
			}
			if(nodetypes.indexOf("fushuss")<0){
				if(nodetypes.indexOf("pointAnode")>=0||
				   nodetypes.indexOf("pointPole")>=0||
				   nodetypes.indexOf("pointDrainage")>=0
				   )
				{
					JSONObject root = GenerateNode("fsssroot"+pipeLineNO,"gx"+pipeLineNO,"附属设施",true);
					jsonArray.add(root);
					//阳极
					if (nodetypes.indexOf("pointAnode")>=0){
						JSONObject yangjiroot = GenerateNode("pointAnodeRoot"+pipeLineNO,"fsssroot"+pipeLineNO,"阳极",true);
						jsonArray.add(yangjiroot);	
					}			
					//显示测试桩
					if (nodetypes.indexOf("pointPole")>=0){
						JSONObject ceshizhuangroot = GenerateNode("pointPoleRoot"+pipeLineNO,"fsssroot"+pipeLineNO,"测试桩",true);
						jsonArray.add(ceshizhuangroot);
					}
					//排流装置
					if (nodetypes.indexOf("pointDrainage")>=0){
						JSONObject pailiuzhuangzhiroot = GenerateNode("pointDrainageRoot"+pipeLineNO,"fsssroot"+pipeLineNO,"排流装置",true);
						jsonArray.add(pailiuzhuangzhiroot);
					}
				}
			}
			//生产运行
			if (nodetypes.indexOf("shchyx")>=0){
				JSONObject root = GenerateNode("shchyxRoot"+pipeLineNO,"gx"+pipeLineNO,"生产运行",true);
				jsonArray.add(root);
				//异常
				JSONObject yichangroot = GenerateNode("yichangRoot"+pipeLineNO,"shchyxRoot"+pipeLineNO,"异常",true);
				jsonArray.add(yichangroot);
				//特殊段
				JSONObject teshuduanroot = GenerateNode("teshuduanRoot"+pipeLineNO,"shchyxRoot"+pipeLineNO,"特殊段",true);
				jsonArray.add(teshuduanroot);
				//违章占压
				JSONObject wzzyroot = GenerateNode("wzzyRoot"+pipeLineNO,"shchyxRoot"+pipeLineNO,"违章占压",true);
				jsonArray.add(wzzyroot);
			}
			if(nodetypes.indexOf("shchyx")<0){
				if(nodetypes.indexOf("yichang")>=0||
				   nodetypes.indexOf("teshuduan")>=0||
				   nodetypes.indexOf("wzzy")>=0
				   )
				{
					JSONObject root = GenerateNode("shchyxRoot"+pipeLineNO,"gx"+pipeLineNO,"生产运行",true);
					jsonArray.add(root);
					//异常
					if (nodetypes.indexOf("yichang")>=0){
						JSONObject yichangroot = GenerateNode("yichangRoot"+pipeLineNO,"shchyxRoot"+pipeLineNO,"异常",true);
						jsonArray.add(yichangroot);
					}			
					//特殊段
					if (nodetypes.indexOf("teshuduan")>=0){
						JSONObject teshuduanroot = GenerateNode("teshuduanRoot"+pipeLineNO,"shchyxRoot"+pipeLineNO,"特殊段",true);
						jsonArray.add(teshuduanroot);
					}
					//违章占压
					if (nodetypes.indexOf("wzzy")>=0){
						JSONObject wzzyroot = GenerateNode("wzzyRoot"+pipeLineNO,"shchyxRoot"+pipeLineNO,"违章占压",true);
						jsonArray.add(wzzyroot);
					}
				}
			}
			//生产作业
			if (nodetypes.indexOf("shchzy")>=0){
				JSONObject root = GenerateNode("shchzyRoot"+pipeLineNO,"gx"+pipeLineNO,"生产作业",true);
				jsonArray.add(root);
				//生产作业点
				JSONObject child1 = GenerateNode("shengchanzydRoot"+pipeLineNO,"shchzyRoot"+pipeLineNO,"生产作业点",true);
				jsonArray.add(child1);
				//带气作业机械预制件
				JSONObject child2 = GenerateNode("dqzyjxyzhRoot"+pipeLineNO,"shchzyRoot"+pipeLineNO,"带气作业机械预制件",true);
				jsonArray.add(child2);
			}
			if(nodetypes.indexOf("shchzy")<0){
				if(nodetypes.indexOf("shengchanzyd")>=0||
				   nodetypes.indexOf("dqzyjxyzh")>=0
				   )
				{
					JSONObject root = GenerateNode("shchzyRoot"+pipeLineNO,"gx"+pipeLineNO,"生产作业",true);
					jsonArray.add(root);
					//生产作业点
					if (nodetypes.indexOf("shengchanzyd")>=0){
						JSONObject child1 = GenerateNode("shengchanzydRoot"+pipeLineNO,"shchzyRoot"+pipeLineNO,"生产作业点",true);
						jsonArray.add(child1);
					}			
					//带气作业机械预制件
					if (nodetypes.indexOf("dqzyjxyzh")>=0){
						JSONObject child2 = GenerateNode("dqzyjxyzhRoot"+pipeLineNO,"shchzyRoot"+pipeLineNO,"带气作业机械预制件",true);
						jsonArray.add(child2);
					}
				}
			}
			//事件
			if (nodetypes.indexOf("shijian")>=0){
				JSONObject root = GenerateNode("shijianRoot"+pipeLineNO,"gx"+pipeLineNO,"事件",true);
				jsonArray.add(root);
				
				JSONObject child1 = GenerateNode("sjdRoot"+pipeLineNO,"shijianRoot"+pipeLineNO,"事件点",true);
				jsonArray.add(child1);
				
				JSONObject child2 = GenerateNode("xldRoot"+pipeLineNO,"shijianRoot"+pipeLineNO,"泄漏点",true);
				jsonArray.add(child2);
			}
			if(nodetypes.indexOf("shijian")<0){
				if(nodetypes.indexOf("sjd")>=0||
				   nodetypes.indexOf("xld")>=0
				   )
				{
					JSONObject root = GenerateNode("shijianRoot"+pipeLineNO,"gx"+pipeLineNO,"事件",true);
					jsonArray.add(root);
					
					if (nodetypes.indexOf("sjd")>=0){
						JSONObject child1 = GenerateNode("sjdRoot"+pipeLineNO,"shijianRoot"+pipeLineNO,"事件点",true);
						jsonArray.add(child1);
					}			
					
					if (nodetypes.indexOf("xld")>=0){
						JSONObject child2 = GenerateNode("xldRoot"+pipeLineNO,"shijianRoot"+pipeLineNO,"泄漏点",true);
						jsonArray.add(child2);
					}
				}
			}
			//特征点检查
			if (nodetypes.indexOf("testtzhdjch")>=0){
				JSONObject root = GenerateNode("testtzhdjchRoot"+pipeLineNO,"gx"+pipeLineNO,"特征点检查",true);
				jsonArray.add(root);
			}
			//穿越检查
			if (nodetypes.indexOf("chyjch")>=0){
				JSONObject root = GenerateNode("chyjchRoot"+pipeLineNO,"gx"+pipeLineNO,"穿越检查",true);
				jsonArray.add(root);
			}
			//直接检查
			if (nodetypes.indexOf("zhjjch")>=0){
				JSONObject root = GenerateNode("zhjjchRoot"+pipeLineNO,"gx"+pipeLineNO,"直接检查",true);
				jsonArray.add(root);
			
				JSONObject child1 = GenerateNode("wgjchRoot"+pipeLineNO,"zhjjchRoot"+pipeLineNO,"外观检查",true);
				jsonArray.add(child1);

				JSONObject child2 = GenerateNode("bhjcRoot"+pipeLineNO,"zhjjchRoot"+pipeLineNO,"壁厚检测",true);
				jsonArray.add(child2);
				
				JSONObject child3 = GenerateNode("ffchdjcRoot"+pipeLineNO,"zhjjchRoot"+pipeLineNO,"防腐层厚度检测",true);
				jsonArray.add(child3);
				
				JSONObject child4 = GenerateNode("ffcpsjcRoot"+pipeLineNO,"zhjjchRoot"+pipeLineNO,"防腐层破损检测",true);
				jsonArray.add(child4);
				
				JSONObject child5 = GenerateNode("fshzhkjcRoot"+pipeLineNO,"zhjjchRoot"+pipeLineNO,"腐蚀状况检测",true);
				jsonArray.add(child5);
				
				JSONObject child6 = GenerateNode("shexianjcRoot"+pipeLineNO,"zhjjchRoot"+pipeLineNO,"射线检测",true);
				jsonArray.add(child6);
			}
			if(nodetypes.indexOf("zhjjch")<0){
				if(nodetypes.indexOf("wgjch")>=0||
				   nodetypes.indexOf("bhjc")>=0||
				   nodetypes.indexOf("ffchdjc")>=0||
				   nodetypes.indexOf("ffcpsjc")>=0||
				   nodetypes.indexOf("fshzhkjc")>=0||
				   nodetypes.indexOf("shexianjc")>=0
				   )
				{
					JSONObject root = GenerateNode("zhjjchRoot"+pipeLineNO,"gx"+pipeLineNO,"直接检查",true);
					jsonArray.add(root);
					
					if (nodetypes.indexOf("wgjch")>=0){
						JSONObject child1 = GenerateNode("wgjchRoot"+pipeLineNO,"zhjjchRoot"+pipeLineNO,"外观检查",true);
						jsonArray.add(child1);
					}			
					
					if (nodetypes.indexOf("bhjc")>=0){
						JSONObject child2 = GenerateNode("bhjcRoot"+pipeLineNO,"zhjjchRoot"+pipeLineNO,"壁厚检测",true);
						jsonArray.add(child2);
					}
					
					if (nodetypes.indexOf("ffchdjc")>=0){
						JSONObject child3 = GenerateNode("ffchdjcRoot"+pipeLineNO,"zhjjchRoot"+pipeLineNO,"防腐层厚度检测",true);
						jsonArray.add(child3);
					}
					
					if (nodetypes.indexOf("ffcpsjc")>=0){
						JSONObject child4 = GenerateNode("ffcpsjcRoot"+pipeLineNO,"zhjjchRoot"+pipeLineNO,"防腐层破损检测",true);
						jsonArray.add(child4);
					}
					
					if (nodetypes.indexOf("fshzhkjc")>=0){
						JSONObject child5 = GenerateNode("fshzhkjcRoot"+pipeLineNO,"zhjjchRoot"+pipeLineNO,"腐蚀状况检测",true);
						jsonArray.add(child5);
					}
					
					if (nodetypes.indexOf("shexianjc")>=0){
						JSONObject child6 = GenerateNode("shexianjcRoot"+pipeLineNO,"zhjjchRoot"+pipeLineNO,"射线检测",true);
						jsonArray.add(child6);
					}
				}
			}
			//专项检测
			if (nodetypes.indexOf("zhxjc")>=0){
				JSONObject root = GenerateNode("zhxjcRoot"+pipeLineNO,"gx"+pipeLineNO,"专项检测",true);
				jsonArray.add(root);
				
				JSONObject child1= GenerateNode("dbjcRoot"+pipeLineNO,"zhxjcRoot"+pipeLineNO,"导波检测",true);
				jsonArray.add(child1);
				
				JSONObject child2 = GenerateNode("cjyjcRoot"+pipeLineNO,"zhxjcRoot"+pipeLineNO,"磁记忆检测",true);
				jsonArray.add(child2);
				
				JSONObject child3 = GenerateNode("shbdcjcRoot"+pipeLineNO,"zhxjcRoot"+pipeLineNO,"瞬变电磁检测",true);
				jsonArray.add(child3);
			}
			if(nodetypes.indexOf("zhxjc")<0){
				if(nodetypes.indexOf("dbjc")>=0||
				   nodetypes.indexOf("cjyjc")>=0||
				   nodetypes.indexOf("shbdcjc")>=0
				   )
				{				
					JSONObject root = GenerateNode("zhxjcRoot"+pipeLineNO,"gx"+pipeLineNO,"专项检测",true);
					jsonArray.add(root);
					
					if (nodetypes.indexOf("dbjc")>=0){
						JSONObject child1= GenerateNode("dbjcRoot"+pipeLineNO,"zhxjcRoot"+pipeLineNO,"导波检测",true);
						jsonArray.add(child1);
					}			
					
					if (nodetypes.indexOf("cjyjc")>=0){
						JSONObject child2 = GenerateNode("cjyjcRoot"+pipeLineNO,"zhxjcRoot"+pipeLineNO,"磁记忆检测",true);
						jsonArray.add(child2);
					}
					
					if (nodetypes.indexOf("shbdcjc")>=0){
						JSONObject child3 = GenerateNode("shbdcjcRoot"+pipeLineNO,"zhxjcRoot"+pipeLineNO,"瞬变电磁检测",true);
						jsonArray.add(child3);
					}
				}
			}
			//理化检测
			if (nodetypes.indexOf("lhjc")>=0){
				JSONObject root = GenerateNode("lhjcRoot"+pipeLineNO,"gx"+pipeLineNO,"理化检测",true);
				jsonArray.add(root);
				
				JSONObject child1= GenerateNode("ylshyRoot"+pipeLineNO,"lhjcRoot"+pipeLineNO,"应力试验",true);
				jsonArray.add(child1);
				
				JSONObject child2 = GenerateNode("hxchffxRoot"+pipeLineNO,"lhjcRoot"+pipeLineNO,"化学成分分析",true);
				jsonArray.add(child2);
				
				JSONObject child3 = GenerateNode("ydcshRoot"+pipeLineNO,"lhjcRoot"+pipeLineNO,"硬度测试",true);
				jsonArray.add(child3);
				
				JSONObject child4 = GenerateNode("jxfxRoot"+pipeLineNO,"lhjcRoot"+pipeLineNO,"金相分析",true);
				jsonArray.add(child4);
				
				JSONObject child5 = GenerateNode("lshshyRoot"+pipeLineNO,"lhjcRoot"+pipeLineNO,"拉伸试验",true);
				jsonArray.add(child5);
				
				JSONObject child6 = GenerateNode("wqshiyRoot"+pipeLineNO,"lhjcRoot"+pipeLineNO,"弯曲试验",true);
				jsonArray.add(child6);
				
				JSONObject child7 = GenerateNode("chjshyRoot"+pipeLineNO,"lhjcRoot"+pipeLineNO,"冲击试验",true);
				jsonArray.add(child7);
			}
			if(nodetypes.indexOf("lhjc")<0){
				if(nodetypes.indexOf("ylshy")>=0||
				   nodetypes.indexOf("hxchffx")>=0||
				   nodetypes.indexOf("ydcsh")>=0||
				   nodetypes.indexOf("jxfx")>=0||
				   nodetypes.indexOf("lshshy")>=0||
				   nodetypes.indexOf("wqshiy")>=0||
				   nodetypes.indexOf("chjshy")>=0
				   )
				{				
					JSONObject root = GenerateNode("lhjcRoot"+pipeLineNO,"gx"+pipeLineNO,"理化检测",true);
					jsonArray.add(root);
					
					if (nodetypes.indexOf("ylshy")>=0){
						JSONObject child1= GenerateNode("ylshyRoot"+pipeLineNO,"lhjcRoot"+pipeLineNO,"应力试验",true);
						jsonArray.add(child1);
					}			
					
					if (nodetypes.indexOf("hxchffx")>=0){
						JSONObject child2 = GenerateNode("hxchffxRoot"+pipeLineNO,"lhjcRoot"+pipeLineNO,"化学成分分析",true);
						jsonArray.add(child2);
					}
					
					if (nodetypes.indexOf("ydcsh")>=0){
						JSONObject child3 = GenerateNode("ydcshRoot"+pipeLineNO,"lhjcRoot"+pipeLineNO,"硬度测试",true);
						jsonArray.add(child3);
					}
					
					if (nodetypes.indexOf("jxfx")>=0){
						JSONObject child4 = GenerateNode("jxfxRoot"+pipeLineNO,"lhjcRoot"+pipeLineNO,"金相分析",true);
						jsonArray.add(child4);
					}
					
					if (nodetypes.indexOf("lshshy")>=0){
						JSONObject child5 = GenerateNode("lshshyRoot"+pipeLineNO,"lhjcRoot"+pipeLineNO,"拉伸试验",true);
						jsonArray.add(child5);
					}
					
					if (nodetypes.indexOf("wqshiy")>=0){
						JSONObject child6 = GenerateNode("wqshiyRoot"+pipeLineNO,"lhjcRoot"+pipeLineNO,"弯曲试验",true);
						jsonArray.add(child6);
					}
					
					if (nodetypes.indexOf("chjshy")>=0){
						JSONObject child7 = GenerateNode("chjshyRoot"+pipeLineNO,"lhjcRoot"+pipeLineNO,"冲击试验",true);
						jsonArray.add(child7);
					}
				}
			}
			//泄漏检测
			if (nodetypes.indexOf("xljc")>=0){
				JSONObject root = GenerateNode("xljcRoot"+pipeLineNO,"gx"+pipeLineNO,"泄漏检测",true);
				jsonArray.add(root);
				JSONObject child1 = GenerateNode("xljcjcdRoot"+pipeLineNO,"xljcRoot"+pipeLineNO,"检测点",true);
				jsonArray.add(child1);
				JSONObject child2 = GenerateNode("xljcxldRoot"+pipeLineNO,"xljcRoot"+pipeLineNO,"泄漏点",true);
				jsonArray.add(child2);
			}
			if(nodetypes.indexOf("xljc")<0){
				if(nodetypes.indexOf("xljcjcd")>=0||
				   nodetypes.indexOf("xljcxld")>=0
				   )
				{
					JSONObject root = GenerateNode("xljcRoot"+pipeLineNO,"gx"+pipeLineNO,"泄漏检测",true);
					jsonArray.add(root);
					if (nodetypes.indexOf("xljcjcd")>=0){
						JSONObject child1 = GenerateNode("xljcjcdRoot"+pipeLineNO,"xljcRoot"+pipeLineNO,"检测点",true);
						jsonArray.add(child1);
					}			
					if (nodetypes.indexOf("xljcxld")>=0){
						JSONObject child2 = GenerateNode("xljcxldRoot"+pipeLineNO,"xljcRoot"+pipeLineNO,"泄漏点",true);
						jsonArray.add(child2);
					}
				}
			}
			//腐蚀防护系统检测
			if (nodetypes.indexOf("fshfhjc")>=0){
				JSONObject root = GenerateNode("fshfhjcRoot"+pipeLineNO,"gx"+pipeLineNO,"腐蚀防护系统检测",true);
				jsonArray.add(root);
				JSONObject child1 = GenerateNode("trfshxjcRoot"+pipeLineNO,"fshfhjcRoot"+pipeLineNO,"土壤腐蚀性检测",true);
				jsonArray.add(child1);
				JSONObject child2 = GenerateNode("zsdljcRoot"+pipeLineNO,"fshfhjcRoot"+pipeLineNO,"杂散电流检测",true);
				jsonArray.add(child2);
				JSONObject child3 = GenerateNode("ffcjydzRoot"+pipeLineNO,"fshfhjcRoot"+pipeLineNO,"防腐层绝缘电阻",true);
				jsonArray.add(child3);
				JSONObject child4 = GenerateNode("ffcjcdRoot"+pipeLineNO,"fshfhjcRoot"+pipeLineNO,"防腐层检测点",true);
				jsonArray.add(child4);
				JSONObject child5 = GenerateNode("ffcpsdRoot"+pipeLineNO,"fshfhjcRoot"+pipeLineNO,"防腐层破损点",true);
				jsonArray.add(child5);
				JSONObject child6 = GenerateNode("cshzhjcRoot"+pipeLineNO,"fshfhjcRoot"+pipeLineNO,"测试桩检测",true);
				jsonArray.add(child6);
				JSONObject child7= GenerateNode("yjbhxgjcRoot"+pipeLineNO,"fshfhjcRoot"+pipeLineNO,"阴极保护效果检测",true);
				jsonArray.add(child7);
				JSONObject child8= GenerateNode("yjbhmjgjcdRoot"+pipeLineNO,"fshfhjcRoot"+pipeLineNO,"阴极保护密间隔检测点",true);
				jsonArray.add(child8);
			}
			if(nodetypes.indexOf("fshfhjc")<0){
				if(nodetypes.indexOf("trfshxjc")>=0||
				   nodetypes.indexOf("zsdljc")>=0||
				   nodetypes.indexOf("ffcjydz")>=0||
				   nodetypes.indexOf("ffcjcd")>=0||
				   nodetypes.indexOf("ffcpsd")>=0||
				   nodetypes.indexOf("cshzhjc")>=0||
				   nodetypes.indexOf("yjbhxgjc")>=0||
				   nodetypes.indexOf("yjbhmjgjcd")>=0
				   )
				{
					JSONObject root = GenerateNode("fshfhjcRoot"+pipeLineNO,"gx"+pipeLineNO,"腐蚀防护系统检测",true);
					jsonArray.add(root);
					if (nodetypes.indexOf("trfshxjc")>=0){
						JSONObject child1 = GenerateNode("trfshxjcRoot"+pipeLineNO,"fshfhjcRoot"+pipeLineNO,"土壤腐蚀性检测",true);
						jsonArray.add(child1);
					}			
					if (nodetypes.indexOf("zsdljc")>=0){
						JSONObject child2 = GenerateNode("zsdljcRoot"+pipeLineNO,"fshfhjcRoot"+pipeLineNO,"杂散电流检测",true);
						jsonArray.add(child2);
					}
					if (nodetypes.indexOf("ffcjydz")>=0){
						JSONObject child3 = GenerateNode("ffcjydzRoot"+pipeLineNO,"fshfhjcRoot"+pipeLineNO,"防腐层绝缘电阻",true);
						jsonArray.add(child3);
					}
					if (nodetypes.indexOf("ffcjcd")>=0){
						JSONObject child4 = GenerateNode("ffcjcdRoot"+pipeLineNO,"fshfhjcRoot"+pipeLineNO,"防腐层检测点",true);
						jsonArray.add(child4);
					}
					if (nodetypes.indexOf("ffcpsd")>=0){
						JSONObject child5 = GenerateNode("ffcpsdRoot"+pipeLineNO,"fshfhjcRoot"+pipeLineNO,"防腐层破损点",true);
						jsonArray.add(child5);
					}			
					if (nodetypes.indexOf("cshzhjc")>=0){
						JSONObject child6 = GenerateNode("cshzhjcRoot"+pipeLineNO,"fshfhjcRoot"+pipeLineNO,"测试桩检测",true);
						jsonArray.add(child6);
					}
					if (nodetypes.indexOf("yjbhxgjc")>=0){
						JSONObject child7= GenerateNode("yjbhxgjcRoot"+pipeLineNO,"fshfhjcRoot"+pipeLineNO,"阴极保护效果检测",true);
						jsonArray.add(child7);
					}
					if (nodetypes.indexOf("yjbhmjgjcd")>=0){
						JSONObject child8= GenerateNode("yjbhmjgjcdRoot"+pipeLineNO,"fshfhjcRoot"+pipeLineNO,"阴极保护密间隔检测点",true);
						jsonArray.add(child8);
					}
				}
			}
			//显示导波检测
//			if (nodetypes.indexOf("dbjc")>=0){
//				JSONObject root = GenerateNode("jcshujuRoot"+pipeLineNO,"gx"+pipeLineNO,"检测数据",true);
//				jsonArray.add(root);					
//				root = GenerateNode("dbjcRoot"+pipeLineNO,"jcshujuRoot"+pipeLineNO,"导波检测",true);
//				jsonArray.add(root);
//			}
		}
		pipelinenos=pipelinenos.substring(0,pipelinenos.length());
		getSession().setAttribute("pipelinenos", pipelinenos);
		//getSession().getAttribute("pipelinenos").toString();
		//站箱
		//JSONObject zhanxiangroot = GenerateNode("zhanxiangroot","root","站箱",true);
		JSONObject zhanxiangroot = GenerateNode("zhanxiangRoot","root","站箱",true);
		jsonArray.add(zhanxiangroot);	
		//获得站箱信息
		//strSql = "select t.id,t.stationname from ptem_station t";
		//strSql = "select t.PIPENO,t.stationname,t.stationno from ptem_station t";
		strSql = "select t.PIPENO,t.stationname,t.stationno,t.id from ptem_station t";
		List<Object []> zhanxianglists = dbService.queryDataBySql(strSql);
		for(int i=0;i<zhanxianglists.size();i++){
			Object[] objs = (Object[])zhanxianglists.get(i);
			String pipeno=objs[0].toString();
			String zhanxiangName=objs[1].toString();
			//String stationno=objs[2].toString();
			String zxid=objs[3].toString();
			//JSONObject zhanxiang = GenerateNode("zx"+pipeno,"zhanxiangroot",zhanxiangName,true);
			JSONObject zhanxiangRoot = GenerateNode("zxRoot"+zxid,"zhanxiangRoot",zhanxiangName,true);			
			jsonArray.add(zhanxiangRoot);			
			//站箱
			//JSONObject zhanxiangLeaf = GenerateNode("zx"+pipeno,"zxRoot"+pipeno,zhanxiangName,false);			
			JSONObject zhanxiangLeaf = GenerateNode("zx"+zxid,"zxRoot"+zxid,zhanxiangName,false);						
			jsonArray.add(zhanxiangLeaf);
			//过滤器
			//String sql="select t.LOCATIONNO from ptem_filter t where t.PIPENETNO='";
			//String sql="select t.ID from ptem_filter t where t.PIPENETNO='";
			String sql="select t.ID,t.LOCATIONNO from ptem_filter t where t.PIPENETNO='";
			sql+=pipeno;
			sql+="'";
			List<Object[]> list=dbService.queryDataBySql(sql);
			int num=list.size();
			//JSONObject jsonRoot = GenerateNode("glqroot"+pipeno,"zx"+pipeno,"过滤器",true);
			JSONObject jsonRoot = GenerateNode("glqRoot"+zxid,"zxRoot"+zxid,"过滤器",true);			
			jsonArray.add(jsonRoot);
			for(int j=0;j<num;j++)
			{
				Object[] objsT=list.get(j);
				String glqid=objsT[0].toString();
				String locationno=objsT[1].toString();
				//JSONObject json = GenerateNode("glq"+locationno,"glqroot"+pipeno,locationno,false);
				JSONObject json = GenerateNode("glq"+glqid,"glqRoot"+zxid,locationno,false);				
				jsonArray.add(json);
			}
			//安全阀
			sql="select t.SAFETYVALVENO from ptem_safetyvalve t where t.PIPENETNO='";
			sql+=pipeno;
			sql+="'";
			List<String>listsaftyvalve=dbService.queryDataBySql(sql);
			num=listsaftyvalve.size();
			//jsonRoot = GenerateNode("aqfroot"+pipeno,"zx"+pipeno,"安全阀",true);
			jsonRoot = GenerateNode("aqfRoot"+zxid,"zxRoot"+zxid,"安全阀",true);
			jsonArray.add(jsonRoot);
			for(int j=0;j<num;j++)
			{
				String safetyvalveno=listsaftyvalve.get(j);
				//JSONObject json = GenerateNode("aqf"+safetyvalveno,"aqfroot"+pipeno,safetyvalveno,false);
				JSONObject json = GenerateNode("aqf"+safetyvalveno,"aqfRoot"+zxid,safetyvalveno,false);				
				jsonArray.add(json);
			}
		}
		return jsonArray;	
	}
	
	//管段
	public JSONArray getGuanDuanNode(String id) throws IOException{
		JSONArray jsonArray = new JSONArray();
		String gxid = id.replace("gdroot", "");
		//String strSql = "select t.pipesectionno,t.beginnodel,t.beginnodeb from ptem_pipesection t where t.PIPELINENO='"+gxid+"'";
		String strSql = "select t.pipesectionno,t.beginnodel_map,t.beginnodeb_map from ptem_pipesection t where t.PIPELINENO='"+gxid+"'";		
		List guanduanList = dbService.queryDataBySql(strSql);
		for(int i=0;i<guanduanList.size();i++){
			Object[] objs = (Object[])guanduanList.get(i);
			JSONObject guanduan = new JSONObject();
			guanduan.put("id", "gd"+objs[0]);
			guanduan.put("pId", id);
			guanduan.put("name", objs[0]);
			guanduan.put("isParent", false);
			guanduan.put("beginnodel", objs[1].toString());
			guanduan.put("beginnodeb", objs[2].toString());
			jsonArray.add(guanduan);
		}
		return jsonArray;
	}
	//阀门
	public JSONArray getValveNode(String id) throws IOException{
		JSONArray jsonArray = new JSONArray();
		String gxid=id.replace("valveRoot", "");
		//String strSql="select t.valveno from PTEM_VALVE t where t.pipelineno='"+gxid+"'";
		String strSql="select t.id,t.VALVENAME from PTEM_VALVE t where t.pipelineno='"+gxid+"'";
		//List list=dbService.queryDataBySql(strSql);
		List<Object[]> list=dbService.queryDataBySql(strSql);
		int num=list.size();
		for(int i=0;i<num;i++){
			JSONObject valve=new JSONObject();
			Object[] objs=list.get(i);
			valve.put("id", "valve"+objs[0].toString());
			valve.put("pId", id);			
			valve.put("name", objs[1].toString());
			valve.put("isParent",false);
			jsonArray.add(valve);
		}
		return jsonArray;
	}
	//特征点
	public JSONArray getTZDNode(String id) throws IOException{
		JSONArray jsonArray = new JSONArray();
		String gxid = id.replace("tzroot", "");
		String strSql = "select t.pointno from PTEM_PIPEPOINT t where t.pipelineno='"+gxid+"'";
		List tezhengdList = dbService.queryDataBySql(strSql);
		for(int i=0;i<tezhengdList.size();i++){
			JSONObject tezheng = new JSONObject();
			tezheng.put("id", "tz"+tezhengdList.get(i).toString());
			//tezheng.put("id", "tezhengd"+tezhengdList.get(i).toString());
			tezheng.put("pId", id);
			tezheng.put("name", tezhengdList.get(i).toString());
			tezheng.put("isParent", false);
			jsonArray.add(tezheng);
		}
		return jsonArray;
	}
	//三通
	public JSONArray getTeeNode(String id) throws IOException{
		JSONArray jsonArray = new JSONArray();
		String gxid = id.replace("pointTeeRoot", "");
		String strSql = "select t.TEENO from PTEM_POINT_TEE t where t.pipelineno='"+gxid+"'";
		List list = dbService.queryDataBySql(strSql);
		for(int i=0;i<list.size();i++){
			JSONObject pointTee = new JSONObject();
			pointTee.put("id", "pointTee"+list.get(i).toString());
			pointTee.put("pId", id);
			pointTee.put("name", list.get(i).toString());
			pointTee.put("isParent", false);
			jsonArray.add(pointTee);
		}
		return jsonArray;
	}
	//获取泄漏检测泄漏点
	public JSONArray getNodeXljcxld(String id,String root,String tablename,String fieldname,String fieldnameDis) throws IOException{
		JSONArray jsonArray = new JSONArray();
		String type=root.substring(0,root.length()-4);
		String gxid = id.replace(root, "");
		String sql = "select t.";
		sql+=fieldname;
		sql+=",";
		sql+=fieldnameDis;
		sql+=" from ";
		sql+=tablename;
		sql+=" t where t.pipelineno='"+gxid+"'";
		sql+=" and t.";
		sql+=fieldname;
		sql+=" is not null and t.testresult='疑似泄漏'";
	
		List<Object[]> list = dbService.queryDataBySql(sql);
		for(int i=0;i<list.size();i++){
			Object[] objs=list.get(i);
			JSONObject pointTee = new JSONObject();
			pointTee.put("id", type+objs[0].toString());
			pointTee.put("pId", id);
			String name="";
			if(objs[1]!=null)
			{
				name=objs[1].toString();
			}
			if(objs[2]!=null)
			{
				name+="；"+objs[2].toString();
			}
			pointTee.put("name", name);
			pointTee.put("isParent", false);
			jsonArray.add(pointTee);
		}
		return jsonArray;
	}
	
	//
	public JSONArray getNode(String id,String root,String tablename,String fieldname) throws IOException{
		JSONArray jsonArray = new JSONArray();
		String type=root.substring(0,root.length()-4);
		String gxid = id.replace(root, "");
		String sql = "select t.";
		sql+=fieldname;
		sql+=" from ";
		sql+=tablename;
		sql+=" t where t.pipelineno='"+gxid+"'";
		sql+=" and t.";
		sql+=fieldname;
		sql+=" is not null";
		List list = dbService.queryDataBySql(sql);
		for(int i=0;i<list.size();i++){
			JSONObject pointTee = new JSONObject();
			pointTee.put("id", type+list.get(i).toString());
			pointTee.put("pId", id);
			pointTee.put("name", list.get(i).toString());
			pointTee.put("isParent", false);
			jsonArray.add(pointTee);
		}
		return jsonArray;
	}
	public JSONArray getNodeOperation(String id,String root,String tablename,String fieldname,String fieldnameDis) throws IOException{
		JSONArray jsonArray = new JSONArray();
		String type=root.substring(0,root.length()-4);
		String gxid = id.replace(root, "");
		String sql="select t1.id,t2.eventno from PTEM_OPERATIONS_DATA t1" +
				",PTEM_OPERATIONS t2 where t1.pipelineno='"+gxid+
				"' and t1.parentid=t2.id";
		List<Object[]> list = dbService.queryDataBySql(sql);
		for(int i=0;i<list.size();i++){
			Object[] objs=list.get(i);			
			JSONObject pointTee = new JSONObject();
			//pointTee.put("id", type+list.get(i).toString());
			pointTee.put("id", type+objs[0].toString());
			pointTee.put("pId", id);
			pointTee.put("name", objs[1].toString());
			pointTee.put("isParent", false);
			jsonArray.add(pointTee);
		}
		return jsonArray;
	}
	public JSONArray getNodeChild(String id,String root,String tablename,
			String fieldname,String fieldnameDis,String tablenameParent) throws IOException{
		JSONArray jsonArray = new JSONArray();
		String type=root.substring(0,root.length()-4);
		String gxid = id.replace(root, "");
		String sql="select t1."+fieldname+",t2."+fieldnameDis+" from "+tablename+" t1," 
				+tablenameParent+" t2 where t1.pipelineno='"+gxid+
				"' and t1.parentid=t2.id";
		List<Object[]> list = dbService.queryDataBySql(sql);
		for(int i=0;i<list.size();i++){
			Object[] objs=list.get(i);			
			JSONObject pointTee = new JSONObject();
			//pointTee.put("id", type+list.get(i).toString());
			pointTee.put("id", type+objs[0].toString());
			pointTee.put("pId", id);
			pointTee.put("name", objs[1].toString());
			pointTee.put("isParent", false);
			jsonArray.add(pointTee);
		}
		return jsonArray;
	}
	public JSONArray getNode(String id,String root,String tablename,String fieldname,String fieldnameDis) throws IOException{
		JSONArray jsonArray = new JSONArray();
		String type=root.substring(0,root.length()-4);
		String gxid = id.replace(root, "");
		String sql = "select t.";
		sql+=fieldname;
		sql+=",";
		sql+=fieldnameDis;
		sql+=" from ";
		sql+=tablename;
		sql+=" t where t.pipelineno='"+gxid+"'";
		sql+=" and t.";
		sql+=fieldname;
		sql+=" is not null";
		List<Object[]> list = dbService.queryDataBySql(sql);
		for(int i=0;i<list.size();i++){
			Object[] objs=list.get(i);			
			JSONObject pointTee = new JSONObject();
			//pointTee.put("id", type+list.get(i).toString());
			String name="";
			if(objs[1]!=null)
			{
				name=objs[1].toString();
			}
			if(fieldnameDis.indexOf(",")!=-1)
			{
				if(objs[2]!=null)
				{
					name+="；"+objs[2].toString();
				}				
			}
			pointTee.put("id", type+objs[0].toString());
			pointTee.put("pId", id);
			pointTee.put("name",name );
			pointTee.put("isParent", false);
			jsonArray.add(pointTee);
		}
		return jsonArray;
	}
	//测试桩
	public JSONArray getPoleNode(String id) throws IOException{
		JSONArray jsonArray = new JSONArray();
		String gxid = id.replace("pointPoleRoot", "");
		String strSql = "select t.POLENO from ptem_point_pole t where t.pipelineno='"+gxid+"'";
		List list = dbService.queryDataBySql(strSql);
		for(int i=0;i<list.size();i++){
			JSONObject pointTee = new JSONObject();
			pointTee.put("id", "pointPole"+list.get(i).toString());
			pointTee.put("pId", id);
			pointTee.put("name", list.get(i).toString());
			pointTee.put("isParent", false);
			jsonArray.add(pointTee);
		}
		return jsonArray;
	}
	//违章占压
	public JSONArray getWZZYNode(String id) throws IOException{
		JSONArray jsonArray = new JSONArray();
		String gxid = id.replace("wzzyRoot", "");
		//String strSql = "select t.VIOLATIONNO from PTEM_VIOLATION t where t.pipelineno='"+gxid+"'";
		String strSql = "select t.VIOLATIONNO from PTEM_VIOLATION t where t.pipelineno='"+
		gxid+"' and t.VIOLATIONNO is not null";
		
		List list = dbService.queryDataBySql(strSql);
		for(int i=0;i<list.size();i++){
			JSONObject pointTee = new JSONObject();
			pointTee.put("id", "wzzy"+list.get(i).toString());
			pointTee.put("pId", id);
			pointTee.put("name", list.get(i).toString());
			pointTee.put("isParent", false);
			jsonArray.add(pointTee);
		}
		return jsonArray;
	}
	//导波检测
	public JSONArray getDBJCNode(String id) throws IOException{
		JSONArray jsonArray = new JSONArray();
		String gxid = id.replace("dbjcRoot", "");
		String strSql = "select t.pipeno from ptem_guidedwaves_test t where t.pipelineno='"+gxid+"'";
		List list = dbService.queryDataBySql(strSql);
		for(int i=0;i<list.size();i++){
			JSONObject pointTee = new JSONObject();
			pointTee.put("id", "dbjc"+list.get(i).toString());
			pointTee.put("pId", id);
			pointTee.put("name", list.get(i).toString());
			pointTee.put("isParent", false);
			jsonArray.add(pointTee);
		}
		return jsonArray;
	}
	public void getNodeByID(String id,JSONArray jsonArray) throws IOException{
//		//框架
//		if (id.equals("0")){	
//			jsonArray=getGuanxianTreeRootTypeGxChecked(nodetypes);
//		}
		//管段
		if(id.indexOf("gdroot")==0){
			jsonArray=getGuanDuanNode(id);	
		}
		//阀门
		else if(id.indexOf("valveRoot")==0){
			jsonArray=getValveNode(id);	
		}
		//特征点
		else if(id.indexOf("tzroot")==0){
			jsonArray=getTZDNode(id);	
		}
		//三通
		else if(id.indexOf("pointTeeRoot")==0){
			jsonArray=getTeeNode(id);
		}
		//套管
		else if(id.indexOf("taoguanRoot")==0){
			jsonArray=getNode(id,"taoguanRoot","ptem_point_casing","casingno");
		}
		//弯管
		else if(id.indexOf("wanguanRoot")==0){
			jsonArray=getNode(id,"wanguanRoot","ptem_point_bend","bendno");
		}
		//穿跨越
		else if(id.indexOf("chuankuayRoot")==0){
			jsonArray=getNode(id,"chuankuayRoot","ptem_point_crossing","CROSSINGNO");
		}
		//内衬
		else if(id.indexOf("neichenRoot")==0){
			jsonArray=getNode(id,"neichenRoot","ptem_point_liner","PIPELINENO");
		}
		//阳极
		else if(id.indexOf("pointAnodeRoot")==0){
			jsonArray=getNode(id,"pointAnodeRoot","ptem_point_anode","anodeno");
		}
		//测试桩
		else if(id.indexOf("pointPoleRoot")==0){
			jsonArray=getPoleNode(id);
		}
		//排流装置
		else if(id.indexOf("pointDrainageRoot")==0){
			jsonArray=getNode(id,"pointDrainageRoot","ptem_point_drainage","DRAINAGECODE");
		}
		//异常
		else if(id.indexOf("yichangRoot")==0){
			jsonArray=getNode(id,"yichangRoot","ptem_exception","EXCEPTIONNO");
		}
		//特殊段
		else if(id.indexOf("teshuduanRoot")==0){
			jsonArray=getNode(id,"teshuduanRoot","ptem_special","SPECIALNO");
		}
		//违章占压
		else if(id.indexOf("wzzyRoot")==0){
			jsonArray=getWZZYNode(id);	
		}
		//生产作业点
		else if(id.indexOf("shengchanzydRoot")==0){
			jsonArray=getNode(id,"shengchanzydRoot","ptem_operations","pipeno");				
		}
		//带气作业机械预制件
		else if(id.indexOf("dqzyjxyzhRoot")==0){
			jsonArray=getNode(id,"dqzyjxyzhRoot","ptem_fitting","EVENTNO");				
		}
		//事件点
		else if(id.indexOf("sjdRoot")==0){
			jsonArray=getNode(id,"sjdRoot","ptem_emergency","EVENTNO");				
		}
		//泄漏点
		else if(id.indexOf("xldRoot")==0){
			jsonArray=getNode(id,"xldRoot","ptem_leakpoint","EVENNO");				
		}
		//特征点检查
		else if(id.indexOf("testtzhdjchRoot")==0){
			jsonArray=getNode(id,"testtzhdjchRoot","ptem_point_test","pipeno");				
		}
		//穿越检查
		else if(id.indexOf("chyjchRoot")==0){
			jsonArray=getNode(id,"chyjchRoot","ptem_crossing_test","CROSSINGNO");				
		}
		
		//直接检查
		//外观检查
		else if(id.indexOf("wgjchRoot")==0){
			jsonArray=getNode(id,"wgjchRoot","ptem_apperance_check","LOCATIONNO");
		}
		//壁厚检测
		else if(id.indexOf("bhjcRoot")==0){
			jsonArray=getNode(id,"bhjcRoot","ptem_wallthickness","LOCATIONNO");
		}
		//防腐层厚度检测
		else if(id.indexOf("ffchdjcRoot")==0){
			jsonArray=getNode(id,"ffchdjcRoot","ptem_coatingthickness","LOCATIONNO");
		}
		//防腐层破损检测
		else if(id.indexOf("ffcpsjcRoot")==0){
			jsonArray=getNode(id,"ffcpsjcRoot","ptem_coatingdamaged_test","LOCATIONNO");
		}
		//腐蚀状况检测
		else if(id.indexOf("fshzhkjcRoot")==0){
			jsonArray=getNode(id,"fshzhkjcRoot","ptem_corrosion_test","LOCATIONNO");			
		}	
		//射线检测
		else if(id.indexOf("shexianjcRoot")==0){
			jsonArray=getNode(id,"shexianjcRoot","ptem_radial","LOCATIONNO");			
		}	
		//专项检查	
		//导波检测
		else if(id.indexOf("dbjcRoot")==0){
			jsonArray=getDBJCNode(id);			
		}
		//磁记忆检测
		else if(id.indexOf("cjyjcRoot")==0){
			jsonArray=getNode(id,"cjyjcRoot","ptem_magnetic_test","LOCATIONNO");			
		}	
		//瞬变电磁检测
		else if(id.indexOf("shbdcjcRoot")==0){
			jsonArray=getNode(id,"shbdcjcRoot","ptem_tdem_test","pipeno");			
		}	
		//应力试验
		else if(id.indexOf("ylshyRoot")==0){
			jsonArray=getNode(id,"ylshyRoot","ptem_remainingstress","pipeno");			
		}	
		//化学成分分析
		else if(id.indexOf("hxchffxRoot")==0){
			jsonArray=getNode(id,"hxchffxRoot","ptem_chemical","pipeno");			
		}	
		//硬度测试
		else if(id.indexOf("ydcshRoot")==0){
			jsonArray=getNode(id,"ydcshRoot","ptem_hardness","pipeno");			
		}	
		//金相分析
		else if(id.indexOf("jxfxRoot")==0){
			jsonArray=getNode(id,"jxfxRoot","ptem_metallographic","pipeno");			
		}	
		//拉伸试验
		else if(id.indexOf("lshshyRoot")==0){
			jsonArray=getNode(id,"lshshyRoot","ptem_stretch","pipeno");			
		}	
		//弯曲试验
		else if(id.indexOf("wqshiyRoot")==0){
			jsonArray=getNode(id,"wqshiyRoot","ptem_bend","pipeno");			
		}	
		//冲击试验 
		else if(id.indexOf("chjshyRoot")==0){
			jsonArray=getNode(id,"chjshyRoot","ptem_shock","pipeno");			
		}	
		//泄漏检测检测点
		else if(id.indexOf("xljcjcdRoot")==0){
			jsonArray=getNode(id,"xljcjcdRoot","ptem_leak_test","taskno");			
		}	
		//泄漏检测泄漏点
		else if(id.indexOf("xljcxldRoot")==0){
			jsonArray=getNodeXljcxld(id,"xljcxldRoot","ptem_leak_test","id","locationy,locationx");			
		}	
		//土壤腐蚀性检测
		else if(id.indexOf("trfshxjcRoot")==0){
			jsonArray=getNode(id,"trfshxjcRoot","ptem_soilcorrosion","TESTPOINTNO");			
		}	
		//杂散电流检测
		else if(id.indexOf("zsdljcRoot")==0){
			jsonArray=getNode(id,"zsdljcRoot","ptem_straycurrenttest","STRAYPOINTNO");			
		}
		//防腐层绝缘电阻
		else if(id.indexOf("ffcjydzRoot")==0){
			//jsonArray=getNodeXljcxld(id,"ffcjydzRoot","ptem_straycurrenttest","pipeno");			
		}
		//防腐层检测点
		else if(id.indexOf("ffcjcdRoot")==0){
			jsonArray=getNode(id,"ffcjcdRoot","ptem_risotest_pcm_testdata","pipeno");			
		}
		//防腐层破损点
		else if(id.indexOf("ffcpsdRoot")==0){
			jsonArray=getNode(id,"ffcpsdRoot","ptem_coating_damagedpoint","DAMAGEPOINTNO");			
		}
		//测试桩检测
		else if(id.indexOf("cshzhjcRoot")==0){
			jsonArray=getNode(id,"cshzhjcRoot","ptem_testpileinspect","TESTPILENO");			
		}
		//阴极保护效果检测
		else if(id.indexOf("yjbhxgjcRoot")==0){
			//jsonArray=getNode(id,"yjbhxgjcRoot","ptem_cips_test_data","pipeno");			
		}
		//阴极保护密间隔检测点
		else if(id.indexOf("yjbhmjgjcdRoot")==0){
			jsonArray=getNode(id,"yjbhmjgjcdRoot","ptem_cips_test_data","pipeno");			
		}
	}
	public void getGuanxianTreeTypeGxChecked() throws IOException{
		PrintWriter out=PubMethod.GetPrintWriter();
		JSONArray jsonArrayAll = new JSONArray();
	
		String id = getRequest().getParameter("id");
		if(!id.equals("0")){
			return;
		}
		//String id="";
		String nodetypes = getRequest().getParameter("nodetypes");
		String gxchecked = getRequest().getParameter("gxchecked");
		getSession().setAttribute("pipelinenos",gxchecked);
		JSONArray jsonArrayRoot = new JSONArray();
		jsonArrayRoot=getGuanxianTreeRootTypeGxChecked(nodetypes);
		//jsonArrayAll.add(jsonArrayRoot);
		out.print(jsonArrayRoot.toString());
	}
	public void getTypeNodes() throws IOException{
		setContentType();
		PrintWriter out = getResponse().getWriter();
		String nodetypes = getRequest().getParameter("nodetypes");
		String gxchecked = getRequest().getParameter("gxchecked");
		String g_type = getRequest().getParameter("g_type");
		getSession().setAttribute("pipelinenos",gxchecked);
		//获得管线信息
		String pipelineno=getSession().getAttribute("pipelinenos").toString();
		String pipelinenos[]=pipelineno.split(",");
		int pipelinenum=pipelinenos.length;
		List<JSONArray> jsonArrayList=new ArrayList();
		JSONArray jsonArrayT=new JSONArray();
		for(int i=0;i<pipelinenum;i++){
			String pipeLineNO=pipelinenos[i];
			//String pId="guanxianroot";
			//String nodeId="gx"+pipeLineNO;
			//特征点
			if(g_type.equals("tezhengd"))
			{
				jsonArrayT=getNodesLeaf(pipeLineNO,nodetypes,"tezhengd","tzroot","特征点","PTEM_PIPEPOINT","POINTNO");					
				jsonArrayList.add(jsonArrayT);
			}
			//管件
			else if(g_type.equals("guanjian,pointTee,taoguan,wanguan"))
			{				
				jsonArrayT=getGuanjianNode(pipeLineNO,nodetypes);
				jsonArrayList.add(jsonArrayT);
			}
			//穿跨越
			else if(g_type.equals("chuankuay"))
			{
				jsonArrayT=getNodesLeaf(pipeLineNO,nodetypes,"chuankuay",
						"chuankuayRoot","穿跨越","ptem_point_crossing","CROSSINGNO");					
				jsonArrayList.add(jsonArrayT);	
			}
			//内衬
			else if(g_type.equals("neichen"))
			{
				jsonArrayT=getNodesLeaf(pipeLineNO,nodetypes,"neichen",
						"neichenRoot","内衬","ptem_point_liner","LINERNO");								
				jsonArrayList.add(jsonArrayT);	
			}
			//附属设施
			else if(g_type.equals("fushuss,pointAnode,pointPole,pointDrainage"))
			{
				jsonArrayT=getFushusheshiNode(pipeLineNO,nodetypes);			
				jsonArrayList.add(jsonArrayT);
			}
			//生产运行
			else if(g_type.equals("shchyx,yichang,teshuduan,wzzy"))
			{
				jsonArrayT=getShengchanyunxingNode(pipeLineNO,nodetypes);
				jsonArrayList.add(jsonArrayT);
			}
			//生产作业
			else if(g_type.equals("shchzy,shengchanzyd,dqzyjxyzh"))
			{
				jsonArrayT=getShengchanzuoyeNode(pipeLineNO,nodetypes);
				jsonArrayList.add(jsonArrayT);
			}
			//事件
			else if(g_type.equals("shijian,sjd,xld"))
			{
				jsonArrayT=getShjianNode(pipeLineNO,nodetypes);
				jsonArrayList.add(jsonArrayT);
			}
			//特征点检查
			else if(g_type.equals("testtzhdjch"))
			{
				jsonArrayT=getNodesLeaf(pipeLineNO,nodetypes,"testtzhdjch",
						"testtzhdjchRoot","特征点检查","ptem_point_test","ID","POINTNO");								
				jsonArrayList.add(jsonArrayT);
			}
			//穿越检查
			else if(g_type.equals("chyjch"))
			{
				jsonArrayT=getNodesLeaf(pipeLineNO,nodetypes,"chyjch",
						"chyjchRoot","穿越检查","ptem_crossing_test","ID","CROSSINGNO");								
				jsonArrayList.add(jsonArrayT);
			}
			//直接检查
			else if(g_type.equals("zhjjch,wgjch,bhjc,ffchdjc,ffcpsjc,fshzhkjc,shexianjc"))
			{
				jsonArrayT=getZhijiejianchaNode(pipeLineNO,nodetypes);
				jsonArrayList.add(jsonArrayT);
			}
			//专项检测
			else if(g_type.equals("zhxjc,dbjc,cjyjc,shbdcjc"))
			{
				jsonArrayT=getZhuanxiangjianchaNode(pipeLineNO,nodetypes);
				jsonArrayList.add(jsonArrayT);
			}
			//理化检测
			else if(g_type.equals("lhjc,ylshy,hxchffx,ydcsh,jxfx,lshshy,wqshiy,chjshy"))
			{
				jsonArrayT=getLihuajianceNode(pipeLineNO,nodetypes);
				jsonArrayList.add(jsonArrayT);
			}
			//泄漏检测
			else if(g_type.equals("xieloujc,xljcjcd,xljcxld"))
			{
				jsonArrayT=getXieloujianceNode(pipeLineNO,nodetypes);
				jsonArrayList.add(jsonArrayT);
			}
			//腐蚀防护系统检测
			else if(g_type.equals("fshfhjc,trfshxjc,zsdljc,ffcjcd,ffcpsd,cshzhjc,yjbhmjgjcd"))
			{						
				jsonArrayT=getFushifanghuxitongjianceNode(pipeLineNO,nodetypes);
				jsonArrayList.add(jsonArrayT);
			}			
		}
		out.print(jsonArrayList);
	}
	
	
	public void getGuanxianTreeType() throws IOException{
		PrintWriter out=PubMethod.GetPrintWriter();
		JSONArray jsonArray = new JSONArray();
		String id = getRequest().getParameter("id");
		String nodetypes = getRequest().getParameter("nodetypes");
		//框架
		if (id.equals("0")){	
			jsonArray=getGuanxianTreeRootType(nodetypes);
		}
		//管段
		else if(id.indexOf("gdroot")==0){
			jsonArray=getGuanDuanNode(id);	
		}
		//阀门
		else if(id.indexOf("valveRoot")==0){
			jsonArray=getValveNode(id);	
		}
		//特征点
		else if(id.indexOf("tzroot")==0){
			jsonArray=getTZDNode(id);	
		}
		//三通
		else if(id.indexOf("pointTeeRoot")==0){
			jsonArray=getTeeNode(id);
		}
		//套管
		else if(id.indexOf("taoguanRoot")==0){
			jsonArray=getNode(id,"taoguanRoot","ptem_point_casing","casingno");
		}
		//弯管
		else if(id.indexOf("wanguanRoot")==0){
			jsonArray=getNode(id,"wanguanRoot","ptem_point_bend","bendno");
		}
		//穿跨越
		else if(id.indexOf("chuankuayRoot")==0){
			jsonArray=getNode(id,"chuankuayRoot","ptem_point_crossing","CROSSINGNO");
		}
		//内衬
		else if(id.indexOf("neichenRoot")==0){
			jsonArray=getNode(id,"neichenRoot","ptem_point_liner","PIPELINENO");
		}
		//阳极
		else if(id.indexOf("pointAnodeRoot")==0){
			jsonArray=getNode(id,"pointAnodeRoot","ptem_point_anode","anodeno");
		}
		//测试桩
		else if(id.indexOf("pointPoleRoot")==0){
			jsonArray=getPoleNode(id);
		}
		//排流装置
		else if(id.indexOf("pointDrainageRoot")==0){
			jsonArray=getNode(id,"pointDrainageRoot","ptem_point_drainage","DRAINAGECODE");
		}
		//异常
		else if(id.indexOf("yichangRoot")==0){
			jsonArray=getNode(id,"yichangRoot","ptem_exception","EXCEPTIONNO");
		}
		//特殊段
		else if(id.indexOf("teshuduanRoot")==0){
			jsonArray=getNode(id,"teshuduanRoot","ptem_special","SPECIALNO");
		}
		//违章占压
		else if(id.indexOf("wzzyRoot")==0){
			jsonArray=getWZZYNode(id);	
		}
		//生产作业点
		else if(id.indexOf("shengchanzydRoot")==0){
			jsonArray=getNode(id,"shengchanzydRoot","ptem_operations","pipeno");				
		}
		//带气作业机械预制件
		else if(id.indexOf("dqzyjxyzhRoot")==0){
			jsonArray=getNode(id,"dqzyjxyzhRoot","ptem_fitting","EVENTNO");				
		}
		//事件点
		else if(id.indexOf("sjdRoot")==0){
			jsonArray=getNode(id,"sjdRoot","ptem_emergency","EVENTNO");				
		}
		//泄漏点
		else if(id.indexOf("xldRoot")==0){
			jsonArray=getNode(id,"xldRoot","ptem_leakpoint","EVENNO");				
		}
		//特征点检查
		else if(id.indexOf("testtzhdjchRoot")==0){
			jsonArray=getNode(id,"testtzhdjchRoot","ptem_point_test","pipeno");				
		}
		//穿越检查
		else if(id.indexOf("chyjchRoot")==0){
			jsonArray=getNode(id,"chyjchRoot","ptem_crossing_test","CROSSINGNO");				
		}
		
		//直接检查
		//外观检查
		else if(id.indexOf("wgjchRoot")==0){
			jsonArray=getNode(id,"wgjchRoot","ptem_apperance_check","LOCATIONNO");
		}
		//壁厚检测
		else if(id.indexOf("bhjcRoot")==0){
			jsonArray=getNode(id,"bhjcRoot","ptem_wallthickness","LOCATIONNO");
		}
		//防腐层厚度检测
		else if(id.indexOf("ffchdjcRoot")==0){
			jsonArray=getNode(id,"ffchdjcRoot","ptem_coatingthickness","LOCATIONNO");
		}
		//防腐层破损检测
		else if(id.indexOf("ffcpsjcRoot")==0){
			jsonArray=getNode(id,"ffcpsjcRoot","ptem_coatingdamaged_test","LOCATIONNO");
		}
		//腐蚀状况检测
		else if(id.indexOf("fshzhkjcRoot")==0){
			jsonArray=getNode(id,"fshzhkjcRoot","ptem_corrosion_test","LOCATIONNO");			
		}	
		//射线检测
		else if(id.indexOf("shexianjcRoot")==0){
			jsonArray=getNode(id,"shexianjcRoot","ptem_radial","LOCATIONNO");			
		}	
		//专项检查	
		//导波检测
		else if(id.indexOf("dbjcRoot")==0){
			jsonArray=getDBJCNode(id);			
		}
		//磁记忆检测
		else if(id.indexOf("cjyjcRoot")==0){
			jsonArray=getNode(id,"cjyjcRoot","ptem_magnetic_test","LOCATIONNO");			
		}	
		//瞬变电磁检测
		else if(id.indexOf("shbdcjcRoot")==0){
			jsonArray=getNode(id,"shbdcjcRoot","ptem_tdem_test","pipeno");			
		}	
		//应力试验
		else if(id.indexOf("ylshyRoot")==0){
			jsonArray=getNode(id,"ylshyRoot","ptem_remainingstress","pipeno");			
		}	
		//化学成分分析
		else if(id.indexOf("hxchffxRoot")==0){
			jsonArray=getNode(id,"hxchffxRoot","ptem_chemical","pipeno");			
		}	
		//硬度测试
		else if(id.indexOf("ydcshRoot")==0){
			jsonArray=getNode(id,"ydcshRoot","ptem_hardness","pipeno");			
		}	
		//金相分析
		else if(id.indexOf("jxfxRoot")==0){
			jsonArray=getNode(id,"jxfxRoot","ptem_metallographic","pipeno");			
		}	
		//拉伸试验
		else if(id.indexOf("lshshyRoot")==0){
			jsonArray=getNode(id,"lshshyRoot","ptem_stretch","pipeno");			
		}	
		//弯曲试验
		else if(id.indexOf("wqshiyRoot")==0){
			jsonArray=getNode(id,"wqshiyRoot","ptem_bend","pipeno");			
		}	
		//冲击试验 
		else if(id.indexOf("chjshyRoot")==0){
			jsonArray=getNode(id,"chjshyRoot","ptem_shock","pipeno");			
		}	
		//泄漏检测检测点
		else if(id.indexOf("xljcjcdRoot")==0){
			jsonArray=getNode(id,"xljcjcdRoot","ptem_leak_test","taskno");			
		}	
		//泄漏检测泄漏点
		else if(id.indexOf("xljcxldRoot")==0){
			jsonArray=getNodeXljcxld(id,"xljcxldRoot","ptem_leak_test","id","locationy,locationx");			
		}	
		//土壤腐蚀性检测
		else if(id.indexOf("trfshxjcRoot")==0){
			jsonArray=getNode(id,"trfshxjcRoot","ptem_soilcorrosion","TESTPOINTNO");			
		}	
		//杂散电流检测
		else if(id.indexOf("zsdljcRoot")==0){
			jsonArray=getNode(id,"zsdljcRoot","ptem_straycurrenttest","STRAYPOINTNO");			
		}
		//防腐层绝缘电阻
		else if(id.indexOf("ffcjydzRoot")==0){
			//jsonArray=getNodeXljcxld(id,"ffcjydzRoot","ptem_straycurrenttest","pipeno");			
		}
		//防腐层检测点
		else if(id.indexOf("ffcjcdRoot")==0){
			jsonArray=getNode(id,"ffcjcdRoot","ptem_risotest_pcm_testdata","pipeno");			
		}
		//防腐层破损点
		else if(id.indexOf("ffcpsdRoot")==0){
			jsonArray=getNode(id,"ffcpsdRoot","ptem_coating_damagedpoint","DAMAGEPOINTNO");			
		}
		//测试桩检测
		else if(id.indexOf("cshzhjcRoot")==0){
			jsonArray=getNode(id,"cshzhjcRoot","ptem_testpileinspect","TESTPILENO");			
		}
		//阴极保护效果检测
		else if(id.indexOf("yjbhxgjcRoot")==0){
			//jsonArray=getNode(id,"yjbhxgjcRoot","ptem_cips_test_data","pipeno");			
		}
		//阴极保护密间隔检测点
		else if(id.indexOf("yjbhmjgjcdRoot")==0){
			jsonArray=getNode(id,"yjbhmjgjcdRoot","ptem_cips_test_data","pipeno");			
		}
		out.print(jsonArray.toString());
	}
	
	
	public void getGuanxianTree() throws IOException{
		PrintWriter out=PubMethod.GetPrintWriter();
		JSONArray jsonArray = new JSONArray();
		String id = getRequest().getParameter("id");
		String nodetypes = getRequest().getParameter("nodetypes");
		
		//框架
		if (id.equals("0")){	
			jsonArray=getGuanxianTreeRoot(nodetypes);
		}
		//管段
		else if(id.indexOf("gdroot")==0){
			jsonArray=getGuanDuanNode(id);	
		}
		//阀门
		else if(id.indexOf("valveRoot")==0){
			jsonArray=getValveNode(id);	
		}
		//特征点
		else if(id.indexOf("tzroot")==0){
			jsonArray=getTZDNode(id);	
		}
		//三通
		else if(id.indexOf("pointTeeRoot")==0){
			jsonArray=getTeeNode(id);
		}
		//套管
		else if(id.indexOf("taoguanRoot")==0){
			jsonArray=getNode(id,"taoguanRoot","ptem_point_casing","casingno");
		}
		//弯管
		else if(id.indexOf("wanguanRoot")==0){
			jsonArray=getNode(id,"wanguanRoot","ptem_point_bend","bendno");
		}
		//穿跨越
		else if(id.indexOf("chuankuayRoot")==0){
			jsonArray=getNode(id,"chuankuayRoot","ptem_point_crossing","CROSSINGNO");
		}
		//内衬
		else if(id.indexOf("neichenRoot")==0){
			jsonArray=getNode(id,"neichenRoot","ptem_point_liner","PIPELINENO");
		}
		//阳极
		else if(id.indexOf("pointAnodeRoot")==0){
			jsonArray=getNode(id,"pointAnodeRoot","ptem_point_anode","anodeno");
		}
		//测试桩
		else if(id.indexOf("pointPoleRoot")==0){
			jsonArray=getPoleNode(id);
		}
		//排流装置
		else if(id.indexOf("pointDrainageRoot")==0){
			jsonArray=getNode(id,"pointDrainageRoot","ptem_point_drainage","DRAINAGECODE");
		}
		//异常
		else if(id.indexOf("yichangRoot")==0){
			jsonArray=getNode(id,"yichangRoot","ptem_exception","EXCEPTIONNO");
		}
		//特殊段
		else if(id.indexOf("teshuduanRoot")==0){
			jsonArray=getNode(id,"teshuduanRoot","ptem_special","SPECIALNO");
		}
		//违章占压
		else if(id.indexOf("wzzyRoot")==0){
			jsonArray=getWZZYNode(id);	
		}
		//生产作业点
		else if(id.indexOf("shengchanzydRoot")==0){
			jsonArray=getNode(id,"shengchanzydRoot","ptem_operations","pipeno");				
		}
		//带气作业机械预制件
		else if(id.indexOf("dqzyjxyzhRoot")==0){
			jsonArray=getNode(id,"dqzyjxyzhRoot","ptem_fitting","EVENTNO");				
		}
		//事件点
		else if(id.indexOf("sjdRoot")==0){
			jsonArray=getNode(id,"sjdRoot","ptem_emergency","EVENTNO");				
		}
		//泄漏点
		else if(id.indexOf("xldRoot")==0){
			jsonArray=getNode(id,"xldRoot","ptem_leakpoint","EVENNO");				
		}
		//特征点检查
		else if(id.indexOf("testtzhdjchRoot")==0){
			jsonArray=getNode(id,"testtzhdjchRoot","ptem_point_test","pipeno");				
		}
		//穿越检查
		else if(id.indexOf("chyjchRoot")==0){
			jsonArray=getNode(id,"chyjchRoot","ptem_crossing_test","CROSSINGNO");				
		}
		
		//直接检查
		//外观检查
		else if(id.indexOf("wgjchRoot")==0){
			jsonArray=getNode(id,"wgjchRoot","ptem_apperance_check","LOCATIONNO");
		}
		//壁厚检测
		else if(id.indexOf("bhjcRoot")==0){
			jsonArray=getNode(id,"bhjcRoot","ptem_wallthickness","LOCATIONNO");
		}
		//防腐层厚度检测
		else if(id.indexOf("ffchdjcRoot")==0){
			jsonArray=getNode(id,"ffchdjcRoot","ptem_coatingthickness","LOCATIONNO");
		}
		//防腐层破损检测
		else if(id.indexOf("ffcpsjcRoot")==0){
			jsonArray=getNode(id,"ffcpsjcRoot","ptem_coatingdamaged_test","LOCATIONNO");
		}
		//腐蚀状况检测
		else if(id.indexOf("fshzhkjcRoot")==0){
			jsonArray=getNode(id,"fshzhkjcRoot","ptem_corrosion_test","LOCATIONNO");			
		}	
		//射线检测
		else if(id.indexOf("shexianjcRoot")==0){
			jsonArray=getNode(id,"shexianjcRoot","ptem_radial","LOCATIONNO");			
		}	
		//专项检查	
		//导波检测
		else if(id.indexOf("dbjcRoot")==0){
			jsonArray=getDBJCNode(id);			
		}
		//磁记忆检测
		else if(id.indexOf("cjyjcRoot")==0){
			jsonArray=getNode(id,"cjyjcRoot","ptem_magnetic_test","LOCATIONNO");			
		}	
		//瞬变电磁检测
		else if(id.indexOf("shbdcjcRoot")==0){
			jsonArray=getNode(id,"shbdcjcRoot","ptem_tdem_test","pipeno");			
		}	
		//应力试验
		else if(id.indexOf("ylshyRoot")==0){
			jsonArray=getNode(id,"ylshyRoot","ptem_remainingstress","pipeno");			
		}	
		//化学成分分析
		else if(id.indexOf("hxchffxRoot")==0){
			jsonArray=getNode(id,"hxchffxRoot","ptem_chemical","pipeno");			
		}	
		//硬度测试
		else if(id.indexOf("ydcshRoot")==0){
			jsonArray=getNode(id,"ydcshRoot","ptem_hardness","pipeno");			
		}	
		//金相分析
		else if(id.indexOf("jxfxRoot")==0){
			jsonArray=getNode(id,"jxfxRoot","ptem_metallographic","pipeno");			
		}	
		//拉伸试验
		else if(id.indexOf("lshshyRoot")==0){
			jsonArray=getNode(id,"lshshyRoot","ptem_stretch","pipeno");			
		}	
		//弯曲试验
		else if(id.indexOf("wqshiyRoot")==0){
			jsonArray=getNode(id,"wqshiyRoot","ptem_bend","pipeno");			
		}	
		//冲击试验 
		else if(id.indexOf("chjshyRoot")==0){
			jsonArray=getNode(id,"chjshyRoot","ptem_shock","pipeno");			
		}	
		//泄漏检测检测点
		else if(id.indexOf("xljcjcdRoot")==0){
			jsonArray=getNode(id,"xljcjcdRoot","ptem_leak_test","taskno");			
		}	
		//泄漏检测泄漏点
		else if(id.indexOf("xljcxldRoot")==0){
			jsonArray=getNodeXljcxld(id,"xljcxldRoot","ptem_leak_test","id","loactiony,locationx");			
		}	
		//土壤腐蚀性检测
		else if(id.indexOf("trfshxjcRoot")==0){
			jsonArray=getNode(id,"trfshxjcRoot","ptem_soilcorrosion","TESTPOINTNO");			
		}	
		//杂散电流检测
		else if(id.indexOf("zsdljcRoot")==0){
			jsonArray=getNode(id,"zsdljcRoot","ptem_straycurrenttest","STRAYPOINTNO");			
		}
		//防腐层绝缘电阻
		else if(id.indexOf("ffcjydzRoot")==0){
			//jsonArray=getNodeXljcxld(id,"ffcjydzRoot","ptem_straycurrenttest","pipeno");			
		}
		//防腐层检测点
		else if(id.indexOf("ffcjcdRoot")==0){
			jsonArray=getNode(id,"ffcjcdRoot","ptem_risotest_pcm_testdata","pipeno");			
		}
		//防腐层破损点
		else if(id.indexOf("ffcpsdRoot")==0){
			jsonArray=getNode(id,"ffcpsdRoot","ptem_coating_damagedpoint","DAMAGEPOINTNO");			
		}
		//测试桩检测
		else if(id.indexOf("cshzhjcRoot")==0){
			jsonArray=getNode(id,"cshzhjcRoot","ptem_testpileinspect","TESTPILENO");			
		}
		//阴极保护效果检测
		else if(id.indexOf("yjbhxgjcRoot")==0){
			//jsonArray=getNode(id,"yjbhxgjcRoot","ptem_cips_test_data","pipeno");			
		}
		//阴极保护密间隔检测点
		else if(id.indexOf("yjbhmjgjcdRoot")==0){
			jsonArray=getNode(id,"yjbhmjgjcdRoot","ptem_cips_test_data","pipeno");			
		}
		out.print(jsonArray.toString());
	}
	

	public void getGuanxianpoint() throws IOException{
		PrintWriter out=PubMethod.GetPrintWriter();
		JSONArray jsonArray = new JSONArray();
		String gxid = getRequest().getParameter("gxid").replace("gx", "");
//		String strSql = "select t.node1l,t.node1b,t.node2l,t.node2b,t.node3l,t.node3b," +
//				"t.node4l,t.node4b,t.node5l,t.node5b,t.node6l,t.node6b,t.node7l,t.node7b," +
//				"t.node8l,t.node8b from ptem_pipeline t where t.pipelineno='"+gxid+"'";
//		
		String strSql = "select t.node1l,t.node1b,t.node2l,t.node2b,t.node3l,t.node3b " +
		" from ptem_pipeline t where t.pipelineno='"+gxid+"'";	
		List lists = dbService.queryDataBySql(strSql);
		Object[] objs = (Object[])lists.get(0);
		for(int i=0;i<8;i++){
			int index = i*2;
			if (objs[index]!=null&&!objs[index].toString().equals("")){
				JSONObject jsonobj = new JSONObject();
				jsonobj.put("nodel", objs[index].toString());
				jsonobj.put("nodeb", objs[index+1].toString());
				jsonArray.add(jsonobj);
			}
			else{
				break;
			}
		}
		out.print(jsonArray.toString());
	}
	
//	public void getGuanduanline() throws IOException{
//		PrintWriter out=PubMethod.GetPrintWriter();
//		String gdid = getRequest().getParameter("gdid").replace("gd", "");
////		String strSql = "select t.beginnodel,t.beginnodeb,t.endnodel,t.endnodeb" +
////				" from ptem_pipesection t where t.pipesectionno='"+gdid+"'";
//		String strSql = "select t.beginnodel_map,t.beginnodeb_map,t.endnodel_map,t.endnodeb_map" +
//		" from ptem_pipesection t where t.pipesectionno='"+gdid+"'";
//		List lists = dbService.queryDataBySql(strSql);
//		Object[] objs = (Object[])lists.get(0);
//		JSONObject jsonobj = new JSONObject();
//		jsonobj.put("beginnodel", objs[0]==null?"":objs[0].toString());
//		jsonobj.put("beginnodeb", objs[1]==null?"":objs[1].toString());
//		jsonobj.put("endnodel", objs[2]==null?"":objs[2].toString());
//		jsonobj.put("endnodeb", objs[3]==null?"":objs[3].toString());
//		out.print(jsonobj.toString());
//	}
	
	public void getGuanduanline() throws IOException{
		
		PrintWriter out=PubMethod.GetPrintWriter();
		String gdid = getRequest().getParameter("gdid").replace("gd", "");
		String strSql = "select t.beginnodel_map,t.beginnodeb_map," +
				"t.endnodel_map,t.endnodeb_map,t.PIPELINENO," +
				"t.BEGINNODEY,t.BEGINNODEX,t.BEGINNODEH,"+"t.ENDNODEY,t.ENDNODEX,t.ENDNODEH,"+	
				"t.BEGINNODEL,t.BEGINNODEB,t.BEGINNODEELLIPSOIDH,"+
				"t.ENDNODEL,t.ENDNODEB,t.ENDNODEELLIPSOIDH,"+
				"t.RUNPRESSURELEVEL,t.PRESSURELEVEL,t.AERATEDATE,"+
				"t.PAVEMODE,t.MATERIAL,t.MATERIALMARK,"+
				"t.OUTERDIAMETER,t.THICKNESS,t.PLANELENGTH,"+
				"t.REALLENGTH,t.MANAGEUNIT,t.MANAGEDEPARTMENT,t.REMARK"+
		" from ptem_pipesection t where t.pipesectionno='"+gdid+"'";
		List lists = dbService.queryDataBySql(strSql);
		Object[] objs = (Object[])lists.get(0);
		JSONObject jsonobj = new JSONObject();
		jsonobj.put("beginnodel", objs[0]==null?"":objs[0].toString());
		jsonobj.put("beginnodeb", objs[1]==null?"":objs[1].toString());
		jsonobj.put("endnodel", objs[2]==null?"":objs[2].toString());
		jsonobj.put("endnodeb", objs[3]==null?"":objs[3].toString());
		jsonobj.put("PIPELINENO", objs[4]==null?"":objs[4].toString()); //管线编号
		jsonobj.put("BEGINNODEY", objs[5]==null?"":objs[5].toString()); //起点坐标Y
		jsonobj.put("BEGINNODEX", objs[6]==null?"":objs[6].toString()); //起点坐标X
		jsonobj.put("BEGINNODEH", objs[7]==null?"":objs[7].toString()); //起点高程h
		
		jsonobj.put("ENDNODEY", objs[8]==null?"":objs[8].toString()); //终点坐标Y；
		jsonobj.put("ENDNODEX", objs[9]==null?"":objs[9].toString()); //终点坐标X；
		jsonobj.put("ENDNODEH", objs[10]==null?"":objs[10].toString()); //终点高程h
		
		jsonobj.put("BEGINNODEL", objs[11]==null?"":objs[11].toString()); //起点经度L；
		jsonobj.put("BEGINNODEB", objs[12]==null?"":objs[12].toString()); //起点纬度B；
		jsonobj.put("BEGINNODEELLIPSOIDH", objs[13]==null?"":objs[13].toString()); //起点椭球高H
		
		jsonobj.put("ENDNODEL", objs[14]==null?"":objs[14].toString()); //终点经度L；
		jsonobj.put("ENDNODEB", objs[15]==null?"":objs[15].toString()); //终点纬度B；
		jsonobj.put("ENDNODEELLIPSOIDH", objs[16]==null?"":objs[16].toString()); //终点椭球高H
		
		jsonobj.put("RUNPRESSURELEVEL", objs[17]==null?"":objs[17].toString()); //压力级制（运行单位）
		jsonobj.put("PRESSURELEVEL", objs[18]==null?"":objs[18].toString()); //压力级制
		jsonobj.put("AERATEDATE", objs[19]==null?"":objs[19].toString()); //通气时间
		jsonobj.put("PAVEMODE", objs[20]==null?"":objs[20].toString()); //铺设方式
		jsonobj.put("MATERIAL", objs[21]==null?"":objs[21].toString()); //材质
		jsonobj.put("MATERIALMARK", objs[22]==null?"":objs[22].toString()); //材质牌号
		jsonobj.put("OUTERDIAMETER", objs[23]==null?"":objs[23].toString()); //外径(mm)
		jsonobj.put("THICKNESS", objs[24]==null?"":objs[24].toString()); //壁厚(mm)
		jsonobj.put("PLANELENGTH", objs[25]==null?"":objs[25].toString()); //平面长度(m)
		jsonobj.put("REALLENGTH", objs[26]==null?"":objs[26].toString()); //实际长度(m)
		jsonobj.put("MANAGEUNIT", objs[27]==null?"":objs[27].toString()); //管理单位
		jsonobj.put("MANAGEDEPARTMENT", objs[28]==null?"":objs[28].toString()); //管理部门
		jsonobj.put("REMARK", objs[29]==null?"":objs[29].toString()); //备注
		out.print(jsonobj.toString());
	}


	public void getTezhengdian() throws IOException{
		PrintWriter out=PubMethod.GetPrintWriter();
		String gdid = getRequest().getParameter("tzid").replace("tz", "");
		//String gdid = getRequest().getParameter("tzid").replace("tezhengdian", "");
//		String strSql = "select t1.longitude,t1.latitude,t2.picfilename from ptem_pipepoint t1 " +
//				"left join PTEM_PIPEPOINT_PIC t2 on t1.pointtype=t2.pointtype where t1.pointno='"+gdid+"'";
//		String strSql = "select t1.longitude,t1.latitude,t2.picfilename from ptem_pipepoint t1 " +
//		"left join PTEM_PIPEPOINT_PIC t2 on t1.type=t2.pointtype where t1.pointno='"+gdid+"'";
		String strSql = "select t1.longitude_map,t1.latitude_map,t2.picfilename, "
			+"t1.TYPE,t1.POINTNAME,t1.GROUNDMARK,t1.LOCATIONY,t1.LOCATIONX,t1.HEIGHT,t1.LONGITUDE,t1.LATITUDE,t1.ELLIPSOIDH,t1.PHOTO,t1.REMARK,t1.PIPELINENO,t1.PIPESECTIONNO,t1.ATTACHMENT "
			+" from ptem_pipepoint t1 " +
		"left join PTEM_PIPEPOINT_PIC t2 on t1.type=t2.pointtype where t1.pointno='"+gdid+"'";

		List lists = dbService.queryDataBySql(strSql);
		Object[] objs = (Object[])lists.get(0);
		JSONObject jsonobj = new JSONObject();
		jsonobj.put("longitude", objs[0]==null?"":objs[0].toString());
		jsonobj.put("latitude", objs[1]==null?"":objs[1].toString());
		jsonobj.put("picfilename", objs[2]==null?"":objs[2].toString());
		
		jsonobj.put("POINTTYPE", objs[3]==null?"":objs[3].toString());
		jsonobj.put("POINTNAME", objs[4]==null?"":objs[4].toString());
		jsonobj.put("GROUNDMARK", objs[5]==null?"":objs[5].toString());
		jsonobj.put("LOCATIONY", objs[6]==null?"":objs[6].toString());
		jsonobj.put("LOCATIONX", objs[7]==null?"":objs[7].toString());
		jsonobj.put("HEIGHT", objs[8]==null?"":objs[8].toString());
		jsonobj.put("LONGITUDE", objs[9]==null?"":objs[9].toString());
		jsonobj.put("LATITUDE", objs[10]==null?"":objs[10].toString());
		jsonobj.put("ELLIPSOIDH", objs[11]==null?"":objs[11].toString());		
		jsonobj.put("PHOTO", objs[12]==null?"":objs[12].toString());
		jsonobj.put("REMARK", objs[13]==null?"":objs[13].toString());
		jsonobj.put("PIPELINENO", objs[14]==null?"":objs[14].toString());
		jsonobj.put("PIPESECTIONNO", objs[15]==null?"":objs[15].toString());
		jsonobj.put("ATTACHMENT", objs[16]==null?"":objs[16].toString());
		//jsonobj.put("ATTACHMENT", objs[17]==null?"":objs[17].toString());
		
		out.print(jsonobj.toString());
	}
	
	public void getpoint() throws IOException{
		PrintWriter out=PubMethod.GetPrintWriter();
		String gdid = getRequest().getParameter("tzid").replace("tz", "");
		String strSql = "select t1.longitude,t1.latitude from ptem_pipepoint t1 " +
				"left join PTEM_PIPEPOINT_PIC t2 on t1.pointtype=t2.pointtype where t1.pointno='"+gdid+"'";
		List lists = dbService.queryDataBySql(strSql);
		Object[] objs = (Object[])lists.get(0);
		JSONObject jsonobj = new JSONObject();
		jsonobj.put("longitude", objs[0]==null?"":objs[0].toString());
		jsonobj.put("latitude", objs[1]==null?"":objs[1].toString());
		jsonobj.put("picfilename", objs[2]==null?"":objs[2].toString());
		out.print(jsonobj.toString());
	}
	
	public void getGuanxianTreeByKeyvalue() throws IOException{
		PrintWriter out=PubMethod.GetPrintWriter();
		JSONArray jsonArray = new JSONArray();
		String fieldname = getRequest().getParameter("fieldname");
		String fieldvalue = getRequest().getParameter("fieldvalue");
		
		JSONObject guanwangroot = new JSONObject();
		guanwangroot.put("id", "root");
		guanwangroot.put("pId", "-1");
		guanwangroot.put("name", "北京管网");
		guanwangroot.put("isParent", true);
		guanwangroot.put("open", true);
		jsonArray.add(guanwangroot);
		JSONObject guanxianroot = new JSONObject();
		guanxianroot.put("id", "guanxianroot");
		guanxianroot.put("pId", "root");
		guanxianroot.put("name", "管线");
		guanwangroot.put("isParent", true);
		jsonArray.add(guanxianroot);
		String strSql = "select distinct t2.pipelineno from ptem_pipesection t2 " +
				"where t2."+fieldname+" like '%"+fieldvalue+"%' and t2.pipelineno is not null";
		List guanxianlists = dbService.queryDataBySql(strSql);
		for(int i=0;i<guanxianlists.size();i++){
			JSONObject guanxian = new JSONObject();
			guanxian.put("id", "gx"+guanxianlists.get(i).toString());
			guanxian.put("pId", "guanxianroot");
			guanxian.put("name", guanxianlists.get(i).toString());
			jsonArray.add(guanxian);
			
			JSONObject guanduanroot = new JSONObject();
			guanduanroot.put("id", "gdroot"+guanxianlists.get(i).toString());
			guanduanroot.put("pId", "gx"+guanxianlists.get(i).toString());
			guanduanroot.put("name", "管段");
			guanduanroot.put("isParent", true);
			jsonArray.add(guanduanroot);
			
			strSql = "select t.pipesectionno from ptem_pipesection t where t.PIPELINENO='"+guanxianlists.get(i).toString()+"'";
			List guanduanList = dbService.queryDataBySql(strSql);
			for(int j=0;i<guanduanList.size();j++){
				JSONObject guanduan = new JSONObject();
				guanduan.put("id", "gd"+guanduanList.get(j).toString());
				guanduan.put("pId", "gdroot"+guanxianlists.get(i).toString());
				guanduan.put("name", guanduanList.get(j).toString());
				guanduan.put("isParent", false);
				jsonArray.add(guanduan);
			}
		}
		
		out.print(jsonArray.toString());
	}
	public List<String> splitPipeLine(List<String> guanxianlists)
	{
		List<String> guanxianlistNew=new ArrayList<String>();
		int size=guanxianlists.size();
		for(int i=0;i<size;i++)
		{
			String pipeNoStr=guanxianlists.get(i).toString();
			String pipeNoStrArr[]=pipeNoStr.split("；");
			for(String pipeNo:pipeNoStrArr)
			{
				guanxianlistNew.add(pipeNo);
			}	
		}
		return guanxianlistNew;
	}
	public boolean IsConValInRange(double conVal,String rfieldvalue1,
			String rfieldvalue2,String rlimit1,String rlimit2)
	{
		double rValue1=0;	
		double rValue2=0;
		if(rfieldvalue1!="")
		{
			rValue1=Double.parseDouble(rfieldvalue1);
		}
		if(rfieldvalue2!="")
		{
			rValue2=Double.parseDouble(rfieldvalue2);
		}
		boolean bool=false;
		boolean bool1 = true;
		boolean bool2 = true;
		if(rlimit1.equals("<"))
		{
			bool1=conVal<rValue1;
		}
		if(rlimit1.equals("<="))
		{
			bool1=conVal<=rValue1;
		}
		if(rlimit2.equals(">")){
			bool2=conVal>rValue2;
		}
		if(rlimit2.equals(">=")){
			bool2=conVal>=rValue2;
		}
		bool=bool1&&bool2;
		return bool;
	}
	
	public List<String> getListByAutosearchRangeMulti(String rfieldname,
			String rfieldvalue1,String rlimit1,String rfieldvalue2,
			String rlimit2,String owner) throws IOException{
		List<String> guanxianlists=new ArrayList<String>();
		String strSql="select t.QUERY_TABLE,t.QUERY_FIELD," +
		"t.CONDITION_TABLE,t.CONDITION_FIELD_EN," +
		"MAIN_FIELD,FOREIGN_FIELD from PTEM_SEARCH_RANGE t " +
		//"where t.CONDITION_FIELD_EN='"+rfieldname+
		"where t.CONDITION_FIELD_CN='"+rfieldname+
		"'and t.OWNER='"+owner+"'";
		List<Object[]> objs=dbService.queryDataBySql(strSql);
		if(objs.size()==0)
		{
			return null;
		}
		Object[] obj=new Object[6];
		String query_table="";
		String query_field="";
		String condition_table="";
		String condition_field_en="";
		String main_field="";
		String foreign_field="";
		obj=objs.get(0);
		if(obj[0]!=null)
		{
			query_table=obj[0].toString();
		}
		if(obj[1]!=null)
		{
			query_field=obj[1].toString();
		}
		if(obj[2]!=null)
		{
			condition_table=obj[2].toString();
		}
		if(obj[3]!=null)
		{
			condition_field_en=obj[3].toString();
		}	
		if(obj[4]!=null)
		{
			main_field=obj[4].toString();
		}
		if(obj[5]!=null)
		{
			foreign_field=obj[5].toString();
		}
		if(main_field.equals("")||foreign_field.equals("")) //同一表中查询
		{
			strSql="select "+query_field+","+condition_field_en+" from "+query_table+
			" t where t."+condition_field_en+" is not null";
			List<Object[]> listAll= dbService.queryDataBySql(strSql);
			int num=listAll.size();			
			for(int i=0;i<num;i++)
			{
				Object objT[]=listAll.get(i);
				String query_field_val=objT[0].toString();
				String condition_field_enVal=objT[1].toString();
				//是否为多个值
				String conValArr[]=condition_field_enVal.split("；");
				int valNum=conValArr.length;
				int j=0;
				for(j=0;j<valNum;j++)
				{
					double conVal=Double.parseDouble(conValArr[j]);
					boolean bool=IsConValInRange(conVal,rfieldvalue1,rfieldvalue2,rlimit1,rlimit2);
					if(bool==true)
					{
						break;
					}
				}
				if(j<valNum)
				{
					guanxianlists.add(query_field_val);
				}
			}							
		}
		else  //不同表中查询
		{
			List<String> list = new ArrayList<String>();
			strSql="select t2."+main_field+",t2."+condition_field_en+
			" from "+condition_table+" t2 where t2."+condition_field_en+" is not null";
			List<Object[]> listAll= dbService.queryDataBySql(strSql);
			int num=listAll.size();			
			for(int i=0;i<num;i++)
			{
				Object objT[]=listAll.get(i);
				String query_field_val=objT[0].toString();
				String condition_field_enVal=objT[1].toString();
				//是否为多个值
				String conValArr[]=condition_field_enVal.split("；");
				int valNum=conValArr.length;
				int j=0;
				for(j=0;j<valNum;j++)
				{
					double conVal=Double.parseDouble(conValArr[j]);
					boolean bool=IsConValInRange(conVal,rfieldvalue1,rfieldvalue2,rlimit1,rlimit2);
					if(bool==true)
					{
						break;
					}
				}
				if(j<valNum)
				{
					list.add(query_field_val);
				}
			}							
			int size=list.size();
			if(size==0)
			{
				return null;
			}
			List<String> resultList=new ArrayList();
			for(int i=0;i<size;i++)
			{
				String result=list.get(i);
				String[] fieldValue=result.split("；");
				int numValue=fieldValue.length;
				for(int j=0;j<numValue;j++)
				{
					String str=fieldValue[j];
					resultList.add(str);
				}
			}			
			strSql="select "+query_field+" from "+query_table+" t1 where t1."+
			foreign_field+" in(";
			int numResult=resultList.size();
			for(int k=0;k<numResult;k++)
			{
				strSql+="'"+resultList.get(k)+"',";
			}
			strSql=strSql.substring(0,strSql.length()-1);
			strSql+=")";
			guanxianlists = dbService.queryDataBySql(strSql);
		}
		return guanxianlists;
		//if(query_table.equals("PTEM_TEST_TASK")) //表1 检验检测任务表中的一条记录的多个管线以“；”分隔。
		//{
		//	guanxianlists=splitPipeLine(guanxianlists);
		//}
	}
	
	public List<String> getListByAutosearchRange(String rfieldname,
			String rfieldvalue1,String rlimit1,String rfieldvalue2,
			String rlimit2,String owner) throws IOException{
		List<String> guanxianlists=null;
		String strSql="select t.QUERY_TABLE,t.QUERY_FIELD," +
		"t.CONDITION_TABLE,t.CONDITION_FIELD_EN," +
		"MAIN_FIELD,FOREIGN_FIELD from PTEM_SEARCH_RANGE t " +
		//"where t.CONDITION_FIELD_EN='"+rfieldname+
		"where t.CONDITION_FIELD_CN='"+rfieldname+
		"'and t.OWNER='"+owner+"'";
		List<Object[]> objs=dbService.queryDataBySql(strSql);
		if(objs.size()==0)
		{
			return null;
		}
		Object[] obj=new Object[6];
		String query_table="";
		String query_field="";
		String condition_table="";
		String condition_field_en="";
		String main_field="";
		String foreign_field="";
		obj=objs.get(0);
		if(obj[0]!=null)
		{
			query_table=obj[0].toString();
		}
		if(obj[1]!=null)
		{
			query_field=obj[1].toString();
		}
		if(obj[2]!=null)
		{
			condition_table=obj[2].toString();
		}
		if(obj[3]!=null)
		{
			condition_field_en=obj[3].toString();
		}	
		if(obj[4]!=null)
		{
			main_field=obj[4].toString();
		}
		if(obj[5]!=null)
		{
			foreign_field=obj[5].toString();
		}
		if(main_field.equals("")||foreign_field.equals(""))
		{
			if((rfieldvalue1!=""&rlimit1!="")&(rfieldvalue2!=""&rlimit2!=""))
			{
				strSql="select "+query_field+" from "+query_table+" t where t."+
				condition_field_en+rlimit1+rfieldvalue1+" and t."+condition_field_en
				+rlimit2+rfieldvalue2;
			}
			else if(rfieldvalue1!=""&rlimit1!="")
			{
				strSql="select "+query_field+" from "+query_table+" t where t."+
				condition_field_en+rlimit1+rfieldvalue1;

			}
			else if(rfieldvalue2!=""&rlimit2!="")
			{
				strSql="select "+query_field+" from "+query_table+" t where t."+
				condition_field_en+rlimit2+rfieldvalue2;
			}		
			guanxianlists = dbService.queryDataBySql(strSql);
		}
		else 
		{
			
			if((rfieldvalue1!=""&rlimit1!="")&(rfieldvalue2!=""&rlimit2!=""))
			{
				strSql="select t2."+main_field+" from "+condition_table+
				" t2 where t2."+condition_field_en+rlimit1+rfieldvalue1+" and t2."+condition_field_en+rlimit2+rfieldvalue2;
			}
			else if(rfieldvalue1!=""&rlimit1!="")
			{
				strSql="select t2."+main_field+" from "+condition_table+
				" t2 where t2."+condition_field_en+rlimit1+rfieldvalue1;

			}
			else if(rfieldvalue2!=""&rlimit2!="")
			{
				strSql="select t2."+main_field+" from "+condition_table+
				" t2 where t2."+condition_field_en+rlimit2+rfieldvalue2;
			}		
			List<String> list=dbService.queryDataBySql(strSql);
			int size=list.size();
			if(size==0)
			{
				return null;
			}
			List<String> resultList=new ArrayList();
			for(int i=0;i<size;i++)
			{
				String result=list.get(i);
				String[] fieldValue=result.split("；");
				int num=fieldValue.length;
				for(int j=0;j<num;j++)
				{
					String str=fieldValue[j];
					resultList.add(str);
				}
			}			
			strSql="select "+query_field+" from "+query_table+" t1 where t1."+
			foreign_field+" in(";
			int num=resultList.size();
			for(int k=0;k<num;k++)
			{
				strSql+="'"+resultList.get(k)+"',";
			}
			strSql=strSql.substring(0,strSql.length()-1);
			strSql+=")";
			guanxianlists = dbService.queryDataBySql(strSql);
		}
		return guanxianlists;
		//if(query_table.equals("PTEM_TEST_TASK")) //表1 检验检测任务表中的一条记录的多个管线以“；”分隔。
		//{
		//	guanxianlists=splitPipeLine(guanxianlists);
		//}
	}
//	public List<String> getListByAutosearchDate(String dfieldname,
//			String dfieldvalue1,String dfieldvalue2,String owner) throws IOException{
//		List<String> guanxianlists=null;
//		String strSql="select t.QUERY_TABLE,t.QUERY_FIELD," +
//		"t.CONDITION_TABLE,t.CONDITION_FIELD_EN," +
//		"MAIN_FIELD,FOREIGN_FIELD from PTEM_SEARCH_DATE t " +
//		"where t.CONDITION_FIELD_EN='"+dfieldname+
//		"'and t.OWNER='"+owner+"'";
//		List<Object[]> objs=dbService.queryDataBySql(strSql);
//		if(objs.size()==0)
//		{
//			return null;
//		}
//		Object[] obj=new Object[6];
//		String query_table="";
//		String query_field="";
//		String condition_table="";
//		String condition_field_en="";
//		String main_field="";
//		String foreign_field="";
//		obj=objs.get(0);
//		if(obj[0]!=null)
//		{
//			query_table=obj[0].toString();
//		}
//		if(obj[1]!=null)
//		{
//			query_field=obj[1].toString();
//		}
//		if(obj[2]!=null)
//		{
//			condition_table=obj[2].toString();
//		}
//		if(obj[3]!=null)
//		{
//			condition_field_en=obj[3].toString();
//		}	
//		if(obj[4]!=null)
//		{
//			main_field=obj[4].toString();
//		}
//		if(obj[5]!=null)
//		{
//			foreign_field=obj[5].toString();
//		}
//		if(main_field.equals("")||foreign_field.equals(""))
//		{
//			strSql="select "+query_field+" from "+query_table+" t where t."+
//			condition_field_en+" between to_date('"+ dfieldvalue1+
//			"','YYYY/MM/DD') and to_date('"+dfieldvalue2+"','YYYY/MM/DD')";
//			guanxianlists = dbService.queryDataBySql(strSql);
//		}
//		else 
//		{
//			strSql="select t2."+main_field+" from "+condition_table+
//			" t2 where t2."+condition_field_en+" between to_date('"+ dfieldvalue1+
//			"','YYYY/MM/DD') and to_date('"+dfieldvalue2+"','YYYY/MM/DD')";
//			List<String> list=dbService.queryDataBySql(strSql);
//			int size=list.size();
//			if(size==0)
//			{
//				return null;
//			}
//			List<String> resultList=new ArrayList();
//			for(int i=0;i<size;i++)
//			{
//				String result=list.get(i);
//				String[] fieldValue=result.split("；");
//				int num=fieldValue.length;
//				for(int j=0;j<num;j++)
//				{
//					String str=fieldValue[j];
//					resultList.add(str);
//				}
//			}			
//			strSql="select "+query_field+" from "+query_table+" t1 where t1."+
//			foreign_field+" in(";
//			int num=resultList.size();
//			for(int k=0;k<num;k++)
//			{
//				strSql+="'"+resultList.get(k)+"',";
//			}
//			strSql=strSql.substring(0,strSql.length()-1);
//			strSql+=")";
//			guanxianlists = dbService.queryDataBySql(strSql);
//		}
//		return guanxianlists;
//		//if(query_table.equals("PTEM_TEST_TASK")) //表1 检验检测任务表中的一条记录的多个管线以“；”分隔。
//		//{
//		//	guanxianlists=splitPipeLine(guanxianlists);
//		//}
//	}
//	
	public List<String> getListByAutosearchDate(String dfieldname,
			String dfieldvalue1,String dfieldvalue2,String owner) throws IOException{
		List<String> guanxianlists=null;
		String strSql="select t.QUERY_TABLE,t.QUERY_FIELD," +
		"t.CONNECT_TABLE,t.CONNECT_FIELD,t.CONNECT_FIELD_CON," +
		"t.CONDITION_TABLE,t.CONDITION_FIELD_EN," +
		"MAIN_FIELD,FOREIGN_FIELD from PTEM_SEARCH_DATE t " +
		"where t.CONDITION_FIELD_EN='"+dfieldname+
		"'and t.OWNER='"+owner+"'";
		List<Object[]> objs=dbService.queryDataBySql(strSql);
		if(objs.size()==0)
		{
			return null;
		}
		Object[] obj=new Object[8];
		String query_table="";
		String query_field="";
		String connect_table="";
		String connect_field="";
		String connect_field_con="";
		String condition_table="";
		String condition_field_en="";
		String main_field="";
		String foreign_field="";
		obj=objs.get(0);
		if(obj[0]!=null)
		{
			query_table=obj[0].toString();
		}
		if(obj[1]!=null)
		{
			query_field=obj[1].toString();
		}
		
		if(obj[2]!=null)
		{
			connect_table=obj[2].toString();
		}
		if(obj[3]!=null)
		{
			connect_field=obj[3].toString();	
		}	
		if(obj[4]!=null)
		{
			connect_field_con=obj[4].toString();	
		}
		if(obj[5]!=null)
		{
			condition_table=obj[5].toString();
		}
		if(obj[6]!=null)
		{
			condition_field_en=obj[6].toString();
		}
		if(obj[7]!=null)
		{
			main_field=obj[7].toString();
		}
		if(obj[8]!=null)
		{
			foreign_field=obj[8].toString();
		}
		if(main_field.equals("")||foreign_field.equals(""))
		{
			strSql="select "+query_field+" from "+query_table+" t where t."+
			condition_field_en+" between to_date('"+ dfieldvalue1+
			"','YYYY/MM/DD') and to_date('"+dfieldvalue2+"','YYYY/MM/DD')";
			guanxianlists = dbService.queryDataBySql(strSql);
		}
		else if(connect_field.equals("")||connect_table.equals(""))
		{
			strSql="select t2."+main_field+" from "+condition_table+
			" t2 where t2."+condition_field_en+" between to_date('"+ dfieldvalue1+
			"','YYYY/MM/DD') and to_date('"+dfieldvalue2+"','YYYY/MM/DD')";
			List<String> list=dbService.queryDataBySql(strSql);
			int size=list.size();
			if(size==0)
			{
				return null;
			}
			List<String> resultList=new ArrayList();
			for(int i=0;i<size;i++)
			{
				String result=list.get(i);
				String[] fieldValue=result.split("；");
				int num=fieldValue.length;
				for(int j=0;j<num;j++)
				{
					String str=fieldValue[j];
					resultList.add(str);
				}
			}	

			strSql="select "+query_field+" from "+query_table+" t1 where t1."+
			foreign_field+" in(";

			int num=resultList.size();
			for(int k=0;k<num;k++)
			{
				strSql+="'"+resultList.get(k)+"',";
			}
			strSql=strSql.substring(0,strSql.length()-1);
			strSql+=")";
			guanxianlists = dbService.queryDataBySql(strSql);
		}
		else
		{
			strSql="select t2."+main_field+" from "+condition_table+
			" t2 where t2."+condition_field_en+" between to_date('"+ dfieldvalue1+
			"','YYYY/MM/DD') and to_date('"+dfieldvalue2+"','YYYY/MM/DD')";
			List<String> list=dbService.queryDataBySql(strSql);
			int size=list.size();
			if(size==0)
			{
				return null;
			}
			List<String> resultList=new ArrayList();
			for(int i=0;i<size;i++)
			{
				String result=list.get(i);
				String[] fieldValue=result.split("；");
				int num=fieldValue.length;
				for(int j=0;j<num;j++)
				{
					String str=fieldValue[j];
					resultList.add(str);
				}
			}	

			strSql="select "+query_field+" from "+query_table+" t1 where t1."+
			foreign_field+" in(select t2."+connect_field+" from "+connect_table
			+" t2 where t2."+connect_field_con+" in(";

			int num=resultList.size();
			for(int k=0;k<num;k++)
			{
				strSql+="'"+resultList.get(k)+"',";
			}
			strSql=strSql.substring(0,strSql.length()-1);
			strSql+=")";
			strSql+=")";
			guanxianlists = dbService.queryDataBySql(strSql);
		}
		return guanxianlists;
		//if(query_table.equals("PTEM_TEST_TASK")) //表1 检验检测任务表中的一条记录的多个管线以“；”分隔。
		//{
		//	guanxianlists=splitPipeLine(guanxianlists);
		//}
	}
	
	public List<String> getListByAutosearchKeyword(String kfieldname,
			String kfieldvalue,String owner) throws IOException{
		List<String> guanxianlists=null;
		String strSql="select t.QUERY_TABLE,t.QUERY_FIELD," +
		"t.CONDITION_TABLE,t.CONDITION_FIELD_EN," +
		"MAIN_FIELD,FOREIGN_FIELD from PTEM_SEARCH_KEYWORD t " +
		"where t.CONDITION_FIELD_EN='"+kfieldname+
		"'and t.OWNER='"+owner+"'";
		List<Object[]> objs=dbService.queryDataBySql(strSql);
		if(objs.size()==0)
		{
			return null;
		}
		Object[] obj=new Object[6];
		String query_table="";
		String query_field="";
		String condition_table="";
		String condition_field_en="";
		String main_field="";
		String foreign_field="";
		obj=objs.get(0);
		if(obj[0]!=null)
		{
			query_table=obj[0].toString();
		}
		if(obj[1]!=null)
		{
			query_field=obj[1].toString();
		}
		if(obj[2]!=null)
		{
			condition_table=obj[2].toString();
		}
		if(obj[3]!=null)
		{
			condition_field_en=obj[3].toString();
		}	
		if(obj[4]!=null)
		{
			main_field=obj[4].toString();
		}
		if(obj[5]!=null)
		{
			foreign_field=obj[5].toString();
		}
		if(main_field.equals("")||foreign_field.equals(""))
		{
			//判断是否包含多个
			String kfieldvalues[]=kfieldvalue.split("；");
			int num=kfieldvalues.length;
			if(num==1)
			{
				strSql="select "+query_field+" from "+query_table+" t where t."+
				condition_field_en+" like '%"+kfieldvalue+"%'";
			}
			else
			{
				strSql="select "+query_field+" from "+query_table+" t where ";
				for(int i=0;i<num;i++)
				{
					strSql+="t.";
					strSql+=condition_field_en+" like ";
					strSql+="'%"+kfieldvalues[i]+"%' or";
				}	
				strSql=strSql.substring(0,strSql.length()-2);
				
				
//				strSql="select "+query_field+" from "+query_table+" t where t."+
//				condition_field_en+" in(";
//				for(int i=0;i<num;i++)
//				{
//					strSql+="'"+kfieldvalues[i]+"',";
//				}	
//				strSql=strSql.substring(0,strSql.length()-1);
//				strSql+=")";
			}
			guanxianlists = dbService.queryDataBySql(strSql);
		}
		else 
		{
			//判断是否包含多个
			String kfieldvalues[]=kfieldvalue.split("；");
			int numValue=kfieldvalues.length;
			if(numValue==1)
			{
				strSql="select t2."+main_field+" from "+condition_table+
				" t2 where t2."+condition_field_en+" in('"+kfieldvalue+"')";
				strSql+=" and t2."+main_field+" is not null";
			}
			else
			{
				strSql="select t2."+main_field+" from "+condition_table+
				" t2 where t2."+condition_field_en+" in(";
				for(int i=0;i<numValue;i++)
				{
					strSql+="'"+kfieldvalues[i]+"',";
				}	
				strSql=strSql.substring(0,strSql.length()-1);
				strSql+=")";
				strSql+=" and t2."+main_field+" is not null";
			}
			List<String> list=dbService.queryDataBySql(strSql);
			int size=list.size();
			if(size==0)
			{
				return null;
			}
			List<String> resultList=new ArrayList();
			for(int i=0;i<size;i++)
			{
				String result=list.get(i);
				String[] fieldValue=result.split("；");
				int num=fieldValue.length;
				for(int j=0;j<num;j++)
				{
					String str=fieldValue[j];
					resultList.add(str);
				}
			}			
			strSql="select "+query_field+" from "+query_table+" t1 where t1."+
			foreign_field+" in(";
			int num=resultList.size();
			for(int k=0;k<num;k++)
			{
				strSql+="'"+resultList.get(k)+"',";
			}
			strSql=strSql.substring(0,strSql.length()-1);
			strSql+=")";
			guanxianlists = dbService.queryDataBySql(strSql);
		}
		return guanxianlists;
	}
	
	//特征点关键字查询
//	public List<List <Object[] > > getListByAutosearchKeywordPoint(String kfieldname,
//			String kfieldvalue,String owner) throws IOException{
//		List< List<Object[]> > listAll=new ArrayList();
//		List<Object[]> guanxianlists=null;
//		String strSql="select t.QUERY_TABLE,t.QUERY_FIELD," +
//		"t.CONDITION_TABLE,t.CONDITION_FIELD_EN," +
//		"MAIN_FIELD,FOREIGN_FIELD from PTEM_SEARCH_KEYWORD t " +
//		"where t.CONDITION_FIELD_EN='"+kfieldname+
//		"'and t.OWNER='"+owner+"'";
//		List<Object[]> objs=dbService.queryDataBySql(strSql);
//		if(objs.size()==0)
//		{
//			return null;
//		}
//		Object[] obj=new Object[6];
//		String query_table="";
//		String query_field="";
//		String condition_table="";
//		String condition_field_en="";
//		String main_field="";
//		String foreign_field="";
//		obj=objs.get(0);
//		if(obj[0]!=null)
//		{
//			query_table=obj[0].toString();
//		}
//		if(obj[1]!=null)
//		{
//			query_field=obj[1].toString();
//		}
//		if(obj[2]!=null)
//		{
//			condition_table=obj[2].toString();
//		}
//		if(obj[3]!=null)
//		{
//			condition_field_en=obj[3].toString();
//		}	
//		if(obj[4]!=null)
//		{
//			main_field=obj[4].toString();
//		}
//		if(obj[5]!=null)
//		{
//			foreign_field=obj[5].toString();
//		}
//		String query_fields[]=query_field.split(",");
//		String query_tables[]=query_table.split(",");
//		
//		int queryNum=query_fields.length;
//		String pipelieno="pipelineno";
//		String pipesectionno="pipesectionno";
//		for(int index=0;index<queryNum;index++)
//		{
//			query_field=query_fields[index];
//			query_table=query_tables[index];
//			if(query_table.equals("PTEM_POINT_CROSSING")
//				||query_table.equals("PTEM_POINT_CASING")
//				||query_table.equals("PTEM_EMERGENCY")
//				||query_table.equals("PTEM_LEAKPOINT")
//				||query_table.equals("PTEM_OPERATIONS")
//				||query_table.equals("PTEM_FITTING")
//				)
//			{
//				pipesectionno="PIPENO";
//			}
//			
//			if(main_field.equals("")||foreign_field.equals("")) //同一表中查询
//			{
//				//判断是否包含多个
//				String kfieldvalues[]=kfieldvalue.split("；");
//				int num=kfieldvalues.length;
//				if(num==1)
//				{
//					strSql="select ";
//					strSql+=pipelieno;
//					strSql+=",";
//					//strSql+=pipesectionno;
//					//strSql+=",";
//					strSql+=query_field;
//					strSql+=" from "+query_table+" t where t."+
//					condition_field_en+" like '%"+kfieldvalue+"%'";
//				}
//				else
//				{
//					strSql="select ";
//					strSql+=pipelieno;
//					strSql+=",";
//					//strSql+=pipesectionno;
//					//strSql+=",";
//					strSql+=query_field;
//					strSql+=" from "+query_table+" t where ";
//					for(int i=0;i<num;i++)
//					{
//						strSql+="t.";
//						strSql+=condition_field_en+" like ";
//						strSql+="'%"+kfieldvalues[i]+"%' or";
//					}	
//					strSql=strSql.substring(0,strSql.length()-2);			
//				}
//				guanxianlists = dbService.queryDataBySql(strSql);
//				listAll.add(guanxianlists);
//			}
//			else  //不同表中查询
//			{
//				//判断是否包含多个
//				String kfieldvalues[]=kfieldvalue.split("；");
//				int numValue=kfieldvalues.length;
//				if(numValue==1)
//				{
//					strSql="select t2."+main_field+" from "+condition_table+
//					" t2 where t2."+condition_field_en+" in('"+kfieldvalue+"')";
//					strSql+=" and t2."+main_field+" is not null";
//				}
//				else
//				{
//					strSql="select t2."+main_field+" from "+condition_table+
//					" t2 where t2."+condition_field_en+" in(";
//					for(int i=0;i<numValue;i++)
//					{
//						strSql+="'"+kfieldvalues[i]+"',";
//					}	
//					strSql=strSql.substring(0,strSql.length()-1);
//					strSql+=")";
//					strSql+=" and t2."+main_field+" is not null";
//				}
//				List<String> list=dbService.queryDataBySql(strSql);
//				int size=list.size();
//				if(size==0)
//				{
//					return null;
//				}
//				List<String> resultList=new ArrayList();
//				for(int i=0;i<size;i++)
//				{
//					String result=list.get(i);
//					String[] fieldValue=result.split("；");
//					int num=fieldValue.length;
//					for(int j=0;j<num;j++)
//					{
//						String str=fieldValue[j];
//						resultList.add(str);
//					}
//				}		
//				strSql="select ";
//				strSql+=pipelieno;
//				strSql+=",";
//				//strSql+=pipesectionno;
//				//strSql+=",";
//				strSql+=query_field;
//				strSql+=" from "+query_table+" t1 where t1."+
//				foreign_field+" in(";
//				int num=resultList.size();
//				for(int k=0;k<num;k++)
//				{
//					strSql+="'"+resultList.get(k)+"',";
//				}
//				strSql=strSql.substring(0,strSql.length()-1);
//				strSql+=")";
//				guanxianlists = dbService.queryDataBySql(strSql);
//				listAll.add(guanxianlists);
//			}
//		}
//		return listAll;
//	}
//	
	
	public Map getListByAutosearchKeywordPoint(String kfieldname,
			String kfieldvalue,String owner) throws IOException{
		Map map=new HashMap();
		List< List<Object[]> > listAll=new ArrayList();
		List<Object[]> pointlist=null;
		String strSql="select t.QUERY_TABLE,t.QUERY_FIELD," +
		"t.CONDITION_TABLE,t.CONDITION_FIELD_EN," +
		"MAIN_FIELD,FOREIGN_FIELD,query_type from PTEM_SEARCH_KEYWORD t " +
		"where t.CONDITION_FIELD_EN='"+kfieldname+
		"'and t.OWNER='"+owner+"'";
		List<Object[]> objs=dbService.queryDataBySql(strSql);
		if(objs.size()==0)
		{
			return null;
		}
		Object[] obj=new Object[7];
		String query_table="";
		String query_field="";
		String condition_table="";
		String condition_field_en="";
		String main_field="";
		String foreign_field="";
		String query_type="";
		obj=objs.get(0);
		if(obj[0]!=null)
		{
			query_table=obj[0].toString();
		}
		if(obj[1]!=null)
		{
			query_field=obj[1].toString();
		}
		if(obj[2]!=null)
		{
			condition_table=obj[2].toString();
		}
		if(obj[3]!=null)
		{
			condition_field_en=obj[3].toString();
		}	
		if(obj[4]!=null)
		{
			main_field=obj[4].toString();
		}
		if(obj[5]!=null)
		{
			foreign_field=obj[5].toString();
		}
		if(obj[6]!=null)
		{
			query_type=obj[6].toString();
		}
		String query_fields[]=query_field.split(",");
		String query_tables[]=query_table.split(",");
		String query_types[]=query_type.split(",");
		
		int queryNum=query_fields.length;
		String pipelieno="pipelineno";
		String pipesectionno="pipesectionno";
		for(int index=0;index<queryNum;index++)
		{
			query_field=query_fields[index];
			query_table=query_tables[index];
			query_type=query_types[index];
			if(query_table.equals("PTEM_POINT_CROSSING")
				||query_table.equals("PTEM_POINT_CASING")
				||query_table.equals("PTEM_EMERGENCY")
				||query_table.equals("PTEM_LEAKPOINT")
				||query_table.equals("PTEM_OPERATIONS")
				||query_table.equals("PTEM_FITTING")
				)
			{
				pipesectionno="PIPENO";
			}
			
			if(main_field.equals("")||foreign_field.equals("")) //同一表中查询
			{
				//判断是否包含多个
				String kfieldvalues[]=kfieldvalue.split("；");
				int num=kfieldvalues.length;
				if(num==1)
				{
					strSql="select ";
					strSql+=pipelieno;
					strSql+=",";
					//strSql+=pipesectionno;
					//strSql+=",";
					strSql+=query_field;
					strSql+=" from "+query_table+" t where t."+
					condition_field_en+" like '%"+kfieldvalue+"%'";
				}
				else
				{
					strSql="select ";
					strSql+=pipelieno;
					strSql+=",";
					//strSql+=pipesectionno;
					//strSql+=",";
					strSql+=query_field;
					strSql+=" from "+query_table+" t where ";
					for(int i=0;i<num;i++)
					{
						strSql+="t.";
						strSql+=condition_field_en+" like ";
						strSql+="'%"+kfieldvalues[i]+"%' or";
					}	
					strSql=strSql.substring(0,strSql.length()-2);			
				}
				pointlist = dbService.queryDataBySql(strSql);
				map.put(query_type, pointlist);
				//listAll.add(pointlist);
			}
			else  //不同表中查询
			{
				//判断是否包含多个
				String kfieldvalues[]=kfieldvalue.split("；");
				int numValue=kfieldvalues.length;
				if(numValue==1)
				{
					strSql="select t2."+main_field+" from "+condition_table+
					" t2 where t2."+condition_field_en+" in('"+kfieldvalue+"')";
					strSql+=" and t2."+main_field+" is not null";
				}
				else
				{
					strSql="select t2."+main_field+" from "+condition_table+
					" t2 where t2."+condition_field_en+" in(";
					for(int i=0;i<numValue;i++)
					{
						strSql+="'"+kfieldvalues[i]+"',";
					}	
					strSql=strSql.substring(0,strSql.length()-1);
					strSql+=")";
					strSql+=" and t2."+main_field+" is not null";
				}
				List<String> list=dbService.queryDataBySql(strSql);
				int size=list.size();
				if(size==0)
				{
					return null;
				}
				List<String> resultList=new ArrayList();
				for(int i=0;i<size;i++)
				{
					String result=list.get(i);
					String[] fieldValue=result.split("；");
					int num=fieldValue.length;
					for(int j=0;j<num;j++)
					{
						String str=fieldValue[j];
						resultList.add(str);
					}
				}		
				strSql="select ";
				strSql+=pipelieno;
				strSql+=",";
				//strSql+=pipesectionno;
				//strSql+=",";
				strSql+=query_field;
				strSql+=" from "+query_table+" t1 where t1."+
				foreign_field+" in(";
				int num=resultList.size();
				for(int k=0;k<num;k++)
				{
					strSql+="'"+resultList.get(k)+"',";
				}
				strSql=strSql.substring(0,strSql.length()-1);
				strSql+=")";
				pointlist = dbService.queryDataBySql(strSql);
				map.put(query_type, pointlist);
			}
		}
		return map;
	}
	
	
	public List<String> getListByAutosearchSelectHas(String sfieldname,
			String sfieldvalue,String owner) throws IOException{
		List<String> guanxianlists=null;
		String strSql="select t.QUERY_TABLE,t.QUERY_FIELD," +
		"t.CONDITION_TABLE,t.CONDITION_FIELD_EN," +
		"MAIN_FIELD,FOREIGN_FIELD,t.CONDITION_TABLE_CN from PTEM_SEARCH_SELECT t " +
		"where (t.CONDITION_FIELD_VALUE='"+sfieldname+"' or t.CONDITION_TABLE_CN='"+
		sfieldname+"') and t.OWNER='"+owner+"'";
		List<Object[]> objs=dbService.queryDataBySql(strSql);
		if(objs.size()==0)
		{
			return null;
		}
		Object[] obj=new Object[7];
		String query_table="";
		
		String query_field="";
		String condition_table="";
		String condition_table_cn="";
		String condition_field_en="";
		String main_field="";
		String foreign_field="";
		String condition_field_value="";
		obj=objs.get(0);
		if(obj[0]!=null)
		{
			query_table=obj[0].toString();
		}
		if(obj[1]!=null)
		{
			query_field=obj[1].toString();
		}
		if(obj[2]!=null)
		{
			condition_table=obj[2].toString();
		}
		if(obj[3]!=null)
		{
			condition_field_en=obj[3].toString();
		}	
		if(obj[4]!=null)
		{
			main_field=obj[4].toString();
		}
		if(obj[5]!=null)
		{
			foreign_field=obj[5].toString();
		}
		if(obj[6]!=null)
		{
			condition_table_cn=obj[6].toString();
		}
		
		if(main_field.equals("")||foreign_field.equals(""))
		{
			if(condition_field_en.equals(""))
			{
				return null;
			}
			else
			{
				strSql="select "+query_field+" from "+query_table+" t where t."+
				condition_field_en+" ='"+sfieldname+"'";
			}		
			guanxianlists = dbService.queryDataBySql(strSql);
		}
		else 
		{
			if(condition_field_en.equals(""))
			{
				strSql="select t2."+main_field+" from "+condition_table+
				" t2";
			}
			else
			{
				strSql="select t2."+main_field+" from "+condition_table+
				" t2 where t2."+condition_field_en+" ='"+sfieldname+"'";
			}
			
			List<String> list=dbService.queryDataBySql(strSql);
			int size=list.size();
			if(size==0)
			{
				return null;
			}
			List<String> resultList=new ArrayList();
			for(int i=0;i<size;i++)
			{
				String result=list.get(i);
				if(result==null)
				{
					continue;
				}
				String[] fieldValue=result.split("；");
				int num=fieldValue.length;
				for(int j=0;j<num;j++)
				{
					String str=fieldValue[j];
					resultList.add(str);
				}
			}			
			
			int num=resultList.size();
			if(num==0)
			{
				return null;
			}
//			strSql="select "+query_field+" from "+query_table+" t1 where t1."+
//			foreign_field+" "+sfieldvalue+"(";
			
			strSql="select "+query_field+" from "+query_table+" t1 where";
			
			
			int group;
			if(num%1000==0)
			{
				group=num/1000;
			}
			else
			{
				group=num/1000+1;
			}
			for(int k=0;k<group;k++)
			{
				strSql+=" t1."+foreign_field+" "+sfieldvalue+"(";
				for(int m=0;m<1000;m++)
				{
					int index=k*1000+m;
					if(index>=num)
					{
						break;
					}
					strSql+="'"+resultList.get(index)+"',";
				}
				strSql=strSql.substring(0,strSql.length()-1);
				strSql+=") or";
			}
			strSql=strSql.substring(0,strSql.length()-2);
			
			guanxianlists = dbService.queryDataBySql(strSql);
		}
		return guanxianlists;
		//if(query_table.equals("PTEM_TEST_TASK")) //表1 检验检测任务表中的一条记录的多个管线以“；”分隔。
		//{
		//	guanxianlists=splitPipeLine(guanxianlists);
		//}
	}
	
//	public List<String> getListByAutosearchSelect(String sfieldname,
//			String sfieldvalue,String owner) throws IOException{
//		List<String> guanxianlists=null;
//		String strSql="select t.QUERY_TABLE,t.QUERY_FIELD," +
//		"t.CONDITION_TABLE,t.CONDITION_FIELD_EN," +
//		"MAIN_FIELD,FOREIGN_FIELD from PTEM_SEARCH_SELECT t " +
//		"where t.DICTIONARY_TABLE='"+sfieldname+
//		"'and t.OWNER='"+owner+"'";
//		List<Object[]> objs=dbService.queryDataBySql(strSql);
//		if(objs.size()==0)
//		{
//			return null;
//		}
//		Object[] obj=new Object[6];
//		String query_table="";
//		String query_field="";
//		String condition_table="";
//		String condition_field_en="";
//		String main_field="";
//		String foreign_field="";
//		obj=objs.get(0);
//		if(obj[0]!=null)
//		{
//			query_table=obj[0].toString();
//		}
//		if(obj[1]!=null)
//		{
//			query_field=obj[1].toString();
//		}
//		if(obj[2]!=null)
//		{
//			condition_table=obj[2].toString();
//		}
//		if(obj[3]!=null)
//		{
//			condition_field_en=obj[3].toString();
//		}	
//		if(obj[4]!=null)
//		{
//			main_field=obj[4].toString();
//		}
//		if(obj[5]!=null)
//		{
//			foreign_field=obj[5].toString();
//		}
//		if(main_field.equals("")||foreign_field.equals(""))
//		{
//			//判断是否包含多个
//			String sfieldvalues[]=sfieldvalue.split("\\,");
//			int num=sfieldvalues.length;
//			if(num==1)
//			{
//				strSql="select "+query_field+" from "+query_table+" t where t."+
//				condition_field_en+" in('"+sfieldvalue+"')";
//			}
//			else
//			{
//				strSql="select "+query_field+" from "+query_table+" t where t."+
//				condition_field_en+" in(";
//				for(int i=0;i<num;i++)
//				{
//					strSql+="'"+sfieldvalues[i]+"',";
//				}	
//				strSql=strSql.substring(0,strSql.length()-1);
//				strSql+=")";
//			}			
////			strSql="select "+query_field+" from "+query_table+" t where t."+
////			condition_field_en+" in('"+sfieldvalue+"')";
//			guanxianlists = dbService.queryDataBySql(strSql);
//		}
//		else 
//		{
//			//判断是否包含多个
//			String sfieldvalues[]=sfieldvalue.split("\\,");
//			int numValue=sfieldvalues.length;
//			if(numValue==1)
//			{
//				strSql="select t2."+main_field+" from "+condition_table+
//				" t2 where t2."+condition_field_en+" in('"+sfieldvalue+"')";
//			}
//			else
//			{
//				strSql="select t2."+main_field+" from "+condition_table+
//				" t2 where t2."+condition_field_en+" in(";			
//				for(int i=0;i<numValue;i++)
//				{
//					strSql+="'"+sfieldvalues[i]+"',";
//				}	
//				strSql=strSql.substring(0,strSql.length()-1);
//				strSql+=")";
//			}			
//			strSql="select t2."+main_field+" from "+condition_table+
//			" t2 where t2."+condition_field_en+" in('"+sfieldvalue+"')";
//			List<String> list=dbService.queryDataBySql(strSql);
//			int size=list.size();
//			if(size==0)
//			{
//				return null;
//			}
//			List<String> resultList=new ArrayList();
//			for(int i=0;i<size;i++)
//			{
//				if(list.get(i)==null)
//				{
//					continue;
//				}
//				String result=list.get(i);
//				String[] fieldValue=result.split("；");
//				int num=fieldValue.length;
//				for(int j=0;j<num;j++)
//				{
//					String str=fieldValue[j];
//					resultList.add(str);
//				}
//			}			
//			if(resultList.size()==0)
//			{
//				return null;
//			}
//			strSql="select "+query_field+" from "+query_table+" t1 where t1."+
//			foreign_field+" in(";
//			int num=resultList.size();
//			for(int k=0;k<num;k++)
//			{
//				strSql+="'"+resultList.get(k)+"',";
//			}
//			strSql=strSql.substring(0,strSql.length()-1);
//			strSql+=")";
//			guanxianlists = dbService.queryDataBySql(strSql);
//		}
//		return guanxianlists;
//		//if(query_table.equals("PTEM_TEST_TASK")) //表1 检验检测任务表中的一条记录的多个管线以“；”分隔。
//		//{
//		//	guanxianlists=splitPipeLine(guanxianlists);
//		//}
//	}
	
	public List<String> getListByAutosearchSelect(String sfieldname,
			String sfieldvalue,String owner) throws IOException{
		List<String> guanxianlists=null;
		String strSql="select t.QUERY_TABLE,t.QUERY_FIELD," +
		"t.CONNECT_TABLE,t.CONNECT_FIELD,t.CONNECT_FIELD_CON," +
		"t.CONDITION_TABLE,t.CONDITION_FIELD_EN," +
		"MAIN_FIELD,FOREIGN_FIELD from PTEM_SEARCH_SELECT t " +
		"where t.DICTIONARY_TABLE='"+sfieldname+
		"'and t.OWNER='"+owner+"'";
		List<Object[]> objs=dbService.queryDataBySql(strSql);
		if(objs.size()==0)
		{
			return null;
		}
		Object[] obj=new Object[9];
		String query_table="";
		String query_field="";
		String condition_table="";
		String condition_field_en="";
		String main_field="";
		String foreign_field="";
		String connect_table="";
		String connect_field="";
		String connect_field_con="";
		obj=objs.get(0);
		if(obj[0]!=null)
		{
			query_table=obj[0].toString();
		}
		if(obj[1]!=null)
		{
			query_field=obj[1].toString();
		}
		if(obj[2]!=null)
		{
			connect_table=obj[2].toString();
		}
		if(obj[3]!=null)
		{
			connect_field=obj[3].toString();	
		}	
		if(obj[4]!=null)
		{
			connect_field_con=obj[4].toString();	
		}
		if(obj[5]!=null)
		{
			condition_table=obj[5].toString();
		}
		if(obj[6]!=null)
		{
			condition_field_en=obj[6].toString();
		}
		if(obj[7]!=null)
		{
			main_field=obj[7].toString();
		}
		if(obj[8]!=null)
		{
			foreign_field=obj[8].toString();
		}
		if(sfieldname.equals("PTEM_TYPE_TESTITEM"))
		{
			//判断是否包含多个
			String sfieldvalues[]=sfieldvalue.split("\\,");
			int numValue=sfieldvalues.length;
			String sql="";
			if(numValue==1)
			{
				sql="select t1.taskno from ptem_test_task t1 where t1.taskno in (";
				sql+="select t2.taskno from ";
				sql+=sfieldvalues[0];
				sql+=" t2 ";
				sql+=")";
			}
			else
			{
				sql="select t1.taskno from ptem_test_task t1 where t1.taskno in (";
				sql+="select t2.taskno from ";
				sql+=sfieldvalues[0];
				sql+=" t2 ";
				sql+=")";
				for(int j=1;j<numValue;j++)
				{
					String tablename=sfieldvalues[j];		
					Integer no=j+2;
					String tableno="t"+no.toString();
					sql+=" or t1.taskno in (select ";
					sql+=tableno;
					sql+=".taskno from ";
					sql+=tablename;
					sql+=" ";
					sql+=tableno;
					sql+=")";
				}
			}
			guanxianlists = dbService.queryDataBySql(sql);
		}
		else if(main_field.equals("")||foreign_field.equals(""))
		{
			//判断是否包含多个
			String sfieldvalues[]=sfieldvalue.split("\\,");
			int num=sfieldvalues.length;
			if(num==1)
			{
				strSql="select "+query_field+" from "+query_table+" t where t."+
				condition_field_en+" in('"+sfieldvalue+"')";
			}
			else
			{
				strSql="select "+query_field+" from "+query_table+" t where t."+
				condition_field_en+" in(";
				for(int i=0;i<num;i++)
				{
					strSql+="'"+sfieldvalues[i]+"',";
				}	
				strSql=strSql.substring(0,strSql.length()-1);
				strSql+=")";
			}			
//			strSql="select "+query_field+" from "+query_table+" t where t."+
//			condition_field_en+" in('"+sfieldvalue+"')";
			guanxianlists = dbService.queryDataBySql(strSql);
		}
		else if(connect_field.equals("")||connect_table.equals(""))
		{
			//判断是否包含多个
			String sfieldvalues[]=sfieldvalue.split("\\,");
			int numValue=sfieldvalues.length;
			if(numValue==1)
			{
				strSql="select t2."+main_field+" from "+condition_table+
				" t2 where t2."+condition_field_en+" in('"+sfieldvalue+"')";
			}
			else
			{
				strSql="select t2."+main_field+" from "+condition_table+
				" t2 where t2."+condition_field_en+" in(";			
				for(int i=0;i<numValue;i++)
				{
					strSql+="'"+sfieldvalues[i]+"',";
				}	
				strSql=strSql.substring(0,strSql.length()-1);
				strSql+=")";
			}			
//			strSql="select t2."+main_field+" from "+condition_table+
//			" t2 where t2."+condition_field_en+" in('"+sfieldvalue+"')";
			List<String> list=dbService.queryDataBySql(strSql);
			int size=list.size();
			if(size==0)
			{
				return null;
			}
			List<String> resultList=new ArrayList();
			for(int i=0;i<size;i++)
			{
				if(list.get(i)==null)
				{
					continue;
				}
				String result=list.get(i);
				String[] fieldValue=result.split("；");
				int num=fieldValue.length;
				for(int j=0;j<num;j++)
				{
					String str=fieldValue[j];
					resultList.add(str);
				}
			}			
			if(resultList.size()==0)
			{
				return null;
			}
			strSql="select "+query_field+" from "+query_table+" t1 where t1."+
			foreign_field+" in(";
			int num=resultList.size();
			for(int k=0;k<num;k++)
			{
				strSql+="'"+resultList.get(k)+"',";
			}
			strSql=strSql.substring(0,strSql.length()-1);
			strSql+=")";
			
			guanxianlists = dbService.queryDataBySql(strSql);
		}
		else
		{
			//判断是否包含多个
			String sfieldvalues[]=sfieldvalue.split("\\,");
			int numValue=sfieldvalues.length;
			if(numValue==1)
			{
				strSql="select t2."+main_field+" from "+condition_table+
				" t2 where t2."+condition_field_en+" in('"+sfieldvalue+"')";
			}
			else
			{
				strSql="select t2."+main_field+" from "+condition_table+
				" t2 where t2."+condition_field_en+" in(";			
				for(int i=0;i<numValue;i++)
				{
					strSql+="'"+sfieldvalues[i]+"',";
				}	
				strSql=strSql.substring(0,strSql.length()-1);
				strSql+=")";
			}			
			
		
			
			
			strSql="select t2."+main_field+" from "+condition_table+
			" t2 where t2."+condition_field_en+" in('"+sfieldvalue+"')";
			List<String> list=dbService.queryDataBySql(strSql);
			int size=list.size();
			if(size==0)
			{
				return null;
			}
			List<String> resultList=new ArrayList();
			for(int i=0;i<size;i++)
			{
				if(list.get(i)==null)
				{
					continue;
				}
				String result=list.get(i);
				String[] fieldValue=result.split("；");
				int num=fieldValue.length;
				for(int j=0;j<num;j++)
				{
					String str=fieldValue[j];
					resultList.add(str);
				}
			}			
			if(resultList.size()==0)
			{
				return null;
			}
			
			
			strSql="select "+query_field+" from "+query_table+" t1 where t1."+
			foreign_field+" in(select t2."+connect_field+" from "+connect_table
			+" t2 where t2."+connect_field_con+" in(";
			
//			strSql="select "+query_field+" from "+query_table+" t1 where t1."+
//			foreign_field+" in(";
//			
			
			int num=resultList.size();
			for(int k=0;k<num;k++)
			{
				strSql+="'"+resultList.get(k)+"',";
			}
			strSql=strSql.substring(0,strSql.length()-1);
			strSql+=")";
			strSql+=")";
			guanxianlists = dbService.queryDataBySql(strSql);
		}
		return guanxianlists;
		//if(query_table.equals("PTEM_TEST_TASK")) //表1 检验检测任务表中的一条记录的多个管线以“；”分隔。
		//{
		//	guanxianlists=splitPipeLine(guanxianlists);
		//}
	}
	//特征点查询
	public Map getListByAutosearchSelectPointHas(String sfieldname,
			String sfieldvalue,String owner) throws IOException{
		Map<String, List<Object[]> >  map=new HashMap();
		List<Object[]> pointlist=null;
		String strSql="select t.QUERY_TABLE,t.QUERY_FIELD," +
		"t.CONNECT_TABLE,t.CONNECT_FIELD,t.CONNECT_FIELD_CON," +
		"t.CONDITION_TABLE,t.CONDITION_FIELD_EN," +
		"MAIN_FIELD,FOREIGN_FIELD,query_type from PTEM_SEARCH_SELECT t " +
		"where t.DICTIONARY_TABLE='"+sfieldname+
		"'and t.OWNER='"+owner+"'";
		List<Object[]> objs=dbService.queryDataBySql(strSql);
		if(objs.size()==0)
		{
			return null;
		}
		Object[] obj=new Object[10];
		String query_table="";
		String query_field="";
		String condition_table="";
		String condition_field_en="";
		String main_field="";
		String foreign_field="";
		String connect_table="";
		String connect_field="";
		String connect_field_con="";
		String query_type="";
		obj=objs.get(0);
		if(obj[0]!=null)
		{
			query_table=obj[0].toString();
		}
		if(obj[1]!=null)
		{
			query_field=obj[1].toString();
		}
		if(obj[2]!=null)
		{
			connect_table=obj[2].toString();
		}
		if(obj[3]!=null)
		{
			connect_field=obj[3].toString();	
		}	
		if(obj[4]!=null)
		{
			connect_field_con=obj[4].toString();	
		}
		if(obj[5]!=null)
		{
			condition_table=obj[5].toString();
		}
		if(obj[6]!=null)
		{
			condition_field_en=obj[6].toString();
		}
		if(obj[7]!=null)
		{
			main_field=obj[7].toString();
		}
		if(obj[8]!=null)
		{
			foreign_field=obj[8].toString();
		}
		if(obj[9]!=null)
		{
			query_type=obj[9].toString();
		}
		String pipelineno="pipelineno";
		String sql="select ";
		sql+=pipelineno;
		sql+=",";
		sql+=query_field;
		sql+=" from ";
		sql+=query_table;
		pointlist=dbService.queryDataBySql(sql);
		map.put("特征点", pointlist);
		return map;
	}
	//特征点查询，特征点类型
	public Map getListByAutosearchSelectPointType(String sfieldname,
			String sfieldvalue,String owner) throws IOException{
		Map map=new HashMap();
		List<Object[]> pointlist=null;
		String pipelieno="pipelineno";
		String pipesectionno="pipesectionno";	
		//判断是否包含多个
		String sfieldvalues[]=sfieldvalue.split("\\,");
		int num=sfieldvalues.length;
		String sql;
		List<Object[]> objsDic=new ArrayList();
		if(num==1)
		{
			sql="select t.typename,t.tablename,t.fieldname,t.fieldcon,t.querytype from ";
			sql+=sfieldname;
			sql+=" t where t.typename='";
			sql+=sfieldvalue;
			sql+="'";	
		}
		else
		{
			sql="select t.typename,t.tablename,t.fieldname,t.fieldcon,t.querytype from ";
			sql+=sfieldname;
			sql+=" t where t.typename in(";
			for(int i=0;i<num;i++)
			{
				sql+="'"+sfieldvalues[i]+"',";
			}	
			sql=sql.substring(0,sql.length()-1);
			sql+=")";
		}			
		objsDic= dbService.queryDataBySql(sql);
		int dicNum=objsDic.size();
		List<Object[]> pointType=new ArrayList();		
		for(int k=0;k<dicNum;k++)
		{
			Object[] objdic=objsDic.get(k);
			String typename=objdic[0].toString();
			String tablename=objdic[1].toString();
			String fieldname=objdic[2].toString();
			String querytype=objdic[4].toString();
			String fieldcon="";
			if(objdic[3]!=null)
			{
				fieldcon=objdic[3].toString();
				pointType.add(objdic);
				continue;
			}
			sql="select ";
			sql+=pipelieno;
			sql+=",";
			sql+=fieldname;
			sql+=" from ";
			sql+=tablename;
			List list=dbService.queryDataBySql(sql);
			if(list!=null)
			{
				map.put(querytype, list);
			}
			
		}
		
		String fieldname="POINTNO";
		String tablename="PTEM_PIPEPOINT";
		sql="select ";
		sql+=pipelieno;
		sql+=",";
		sql+=fieldname;
		sql+=" from ";
		sql+=tablename;
		sql+=" where ";
		int pointnum=pointType.size();
		if(pointnum>0)
		{
			Object[] objdic=pointType.get(0);
			String typename=objdic[0].toString();
			String fieldcon=objdic[3].toString();
			sql+=fieldcon;
			sql+="='";
			sql+=typename;
			sql+="'";
			for(int i=1;i<pointnum;i++)
			{
				objdic=pointType.get(i);
				typename=objdic[0].toString();
				fieldcon=objdic[3].toString();
				sql+=" or ";
				sql+=fieldcon;
				sql+="='";
				sql+=typename;
				sql+="'";
			}
			List list=dbService.queryDataBySql(sql);
			if(list!=null&&list.size()!=0)
			{
				map.put("特征点", list);
			}
		}
		
		return map;
	}
	public Map<String, List<Object[]> >  getListByAutosearchSelectPoint(String sfieldname,
			String sfieldvalue,String owner) throws IOException{
		
		Map<String, List<Object[]> >  map=new HashMap();
		List<Object[]> pointlist=null;
		String strSql="select t.QUERY_TABLE,t.QUERY_FIELD," +
		"t.CONNECT_TABLE,t.CONNECT_FIELD,t.CONNECT_FIELD_CON," +
		"t.CONDITION_TABLE,t.CONDITION_FIELD_EN," +
		"MAIN_FIELD,FOREIGN_FIELD,query_type from PTEM_SEARCH_SELECT t " +
		"where t.DICTIONARY_TABLE='"+sfieldname+
		"'and t.OWNER='"+owner+"'";
		List<Object[]> objs=dbService.queryDataBySql(strSql);
		if(objs.size()==0)
		{
			return null;
		}
		Object[] obj=new Object[10];
		String query_table="";
		String query_field="";
		String condition_table="";
		String condition_field_en="";
		String main_field="";
		String foreign_field="";
		String connect_table="";
		String connect_field="";
		String connect_field_con="";
		String query_type="";
		obj=objs.get(0);
		if(obj[0]!=null)
		{
			query_table=obj[0].toString();
		}
		if(obj[1]!=null)
		{
			query_field=obj[1].toString();
		}
		if(obj[2]!=null)
		{
			connect_table=obj[2].toString();
		}
		if(obj[3]!=null)
		{
			connect_field=obj[3].toString();	
		}	
		if(obj[4]!=null)
		{
			connect_field_con=obj[4].toString();	
		}
		if(obj[5]!=null)
		{
			condition_table=obj[5].toString();
		}
		if(obj[6]!=null)
		{
			condition_field_en=obj[6].toString();
		}
		if(obj[7]!=null)
		{
			main_field=obj[7].toString();
		}
		if(obj[8]!=null)
		{
			foreign_field=obj[8].toString();
		}
		if(obj[9]!=null)
		{
			query_type=obj[9].toString();
		}
		String query_fields[]=query_field.split(",");
		String query_tables[]=query_table.split(",");
		String query_types[]=query_type.split(",");
		int queryNum=query_fields.length;
		String pipelieno="pipelineno";
		String pipesectionno="pipesectionno";
		for(int index=0;index<queryNum;index++)
		{
			query_field=query_fields[index];
			query_table=query_tables[index];
			query_type=query_types[index];
			if(query_table.equals("PTEM_POINT_CROSSING")
				||query_table.equals("PTEM_POINT_CASING")
				||query_table.equals("PTEM_EMERGENCY")
				||query_table.equals("PTEM_LEAKPOINT")
				||query_table.equals("PTEM_OPERATIONS")
				||query_table.equals("PTEM_FITTING")
				)
			{
				pipesectionno="PIPENO";
			}
			
		    if(main_field.equals("")||foreign_field.equals(""))
			{
				//判断是否包含多个
				String sfieldvalues[]=sfieldvalue.split("\\,");
				int num=sfieldvalues.length;
				if(num==1)
				{
					strSql="select ";
					strSql+=pipelieno;
					strSql+=",";
					strSql+=query_field+" from "+query_table+" t where t."+
					condition_field_en+" in('"+sfieldvalue+"')";
				}
				else
				{
					strSql="select ";
					strSql+=pipelieno;
					strSql+=",";
					strSql+=query_field+" from "+query_table+" t where t."+
					condition_field_en+" in(";
					for(int i=0;i<num;i++)
					{
						strSql+="'"+sfieldvalues[i]+"',";
					}	
					strSql=strSql.substring(0,strSql.length()-1);
					strSql+=")";
				}			
				pointlist = dbService.queryDataBySql(strSql);
				map.put(query_type, pointlist);
			}
			else if(connect_field.equals("")||connect_table.equals(""))
			{
				//判断是否包含多个
				String sfieldvalues[]=sfieldvalue.split("\\,");
				int numValue=sfieldvalues.length;
				if(numValue==1)
				{
					strSql="select t2."+main_field+" from "+condition_table+
					" t2 where t2."+condition_field_en+" in('"+sfieldvalue+"')";
				}
				else
				{
					strSql="select t2."+main_field+" from "+condition_table+
					" t2 where t2."+condition_field_en+" in(";			
					for(int i=0;i<numValue;i++)
					{
						strSql+="'"+sfieldvalues[i]+"',";
					}	
					strSql=strSql.substring(0,strSql.length()-1);
					strSql+=")";
				}			
				List<String> list=dbService.queryDataBySql(strSql);
				int size=list.size();
				if(size==0)
				{
					return null;
				}
				List<String> resultList=new ArrayList();
				for(int i=0;i<size;i++)
				{
					if(list.get(i)==null)
					{
						continue;
					}
					String result=list.get(i);
					String[] fieldValue=result.split("；");
					int num=fieldValue.length;
					for(int j=0;j<num;j++)
					{
						String str=fieldValue[j];
						resultList.add(str);
					}
				}			
				if(resultList.size()==0)
				{
					return null;
				}
				strSql="select ";
				strSql+=pipelieno;
				strSql+=",";
				strSql+=query_field+" from "+query_table+" t1 where t1."+
				foreign_field+" in(";
				int num=resultList.size();
				for(int k=0;k<num;k++)
				{
					strSql+="'"+resultList.get(k)+"',";
				}
				strSql=strSql.substring(0,strSql.length()-1);
				strSql+=")";
				
				pointlist = dbService.queryDataBySql(strSql);
				map.put(query_type, pointlist);
			}
			else
			{
				//判断是否包含多个
				String sfieldvalues[]=sfieldvalue.split("\\,");
				int numValue=sfieldvalues.length;
				if(numValue==1)
				{
					strSql="select t2."+main_field+" from "+condition_table+
					" t2 where t2."+condition_field_en+" in('"+sfieldvalue+"')";
				}
				else
				{
					strSql="select t2."+main_field+" from "+condition_table+
					" t2 where t2."+condition_field_en+" in(";			
					for(int i=0;i<numValue;i++)
					{
						strSql+="'"+sfieldvalues[i]+"',";
					}	
					strSql=strSql.substring(0,strSql.length()-1);
					strSql+=")";
				}			
				List<String> list=dbService.queryDataBySql(strSql);
				int size=list.size();
				if(size==0)
				{
					return null;
				}
				List<String> resultList=new ArrayList();
				for(int i=0;i<size;i++)
				{
					if(list.get(i)==null)
					{
						continue;
					}
					String result=list.get(i);
					String[] fieldValue=result.split("；");
					int num=fieldValue.length;
					for(int j=0;j<num;j++)
					{
						String str=fieldValue[j];
						resultList.add(str);
					}
				}			
				if(resultList.size()==0)
				{
					return null;
				}
				strSql="select ";
				strSql+=pipelieno;
				strSql+=",";
				strSql+=query_field+" from "+query_table+" t1 where t1."+
				foreign_field+" in(select t2."+connect_field+" from "+connect_table
				+" t2 where t2."+connect_field_con+" in(";
					
				int num=resultList.size();
				for(int k=0;k<num;k++)
				{
					strSql+="'"+resultList.get(k)+"',";
				}
				strSql=strSql.substring(0,strSql.length()-1);
				strSql+=")";
				strSql+=")";
				pointlist = dbService.queryDataBySql(strSql);
				map.put(query_type, pointlist);
			}
		}	
		return map;
	}
	

//	public List< List<Object[]> >  getListByAutosearchSelectPoint(String sfieldname,
//			String sfieldvalue,String owner) throws IOException{
//		List< List<Object[]> > listAll=new ArrayList();
//		List<Object[]> guanxianlists=null;
//		String strSql="select t.QUERY_TABLE,t.QUERY_FIELD," +
//		"t.CONNECT_TABLE,t.CONNECT_FIELD,t.CONNECT_FIELD_CON," +
//		"t.CONDITION_TABLE,t.CONDITION_FIELD_EN," +
//		"MAIN_FIELD,FOREIGN_FIELD from PTEM_SEARCH_SELECT t " +
//		"where t.DICTIONARY_TABLE='"+sfieldname+
//		"'and t.OWNER='"+owner+"'";
//		List<Object[]> objs=dbService.queryDataBySql(strSql);
//		if(objs.size()==0)
//		{
//			return null;
//		}
//		Object[] obj=new Object[9];
//		String query_table="";
//		String query_field="";
//		String condition_table="";
//		String condition_field_en="";
//		String main_field="";
//		String foreign_field="";
//		String connect_table="";
//		String connect_field="";
//		String connect_field_con="";
//		obj=objs.get(0);
//		if(obj[0]!=null)
//		{
//			query_table=obj[0].toString();
//		}
//		if(obj[1]!=null)
//		{
//			query_field=obj[1].toString();
//		}
//		if(obj[2]!=null)
//		{
//			connect_table=obj[2].toString();
//		}
//		if(obj[3]!=null)
//		{
//			connect_field=obj[3].toString();	
//		}	
//		if(obj[4]!=null)
//		{
//			connect_field_con=obj[4].toString();	
//		}
//		if(obj[5]!=null)
//		{
//			condition_table=obj[5].toString();
//		}
//		if(obj[6]!=null)
//		{
//			condition_field_en=obj[6].toString();
//		}
//		if(obj[7]!=null)
//		{
//			main_field=obj[7].toString();
//		}
//		if(obj[8]!=null)
//		{
//			foreign_field=obj[8].toString();
//		}
//		String query_fields[]=query_field.split(",");
//		String query_tables[]=query_table.split(",");
//		
//		int queryNum=query_fields.length;
//		String pipelieno="pipelineno";
//		String pipesectionno="pipesectionno";
//		for(int index=0;index<queryNum;index++)
//		{
//			query_field=query_fields[index];
//			query_table=query_tables[index];
//			if(query_table.equals("PTEM_POINT_CROSSING")
//				||query_table.equals("PTEM_POINT_CASING")
//				||query_table.equals("PTEM_EMERGENCY")
//				||query_table.equals("PTEM_LEAKPOINT")
//				||query_table.equals("PTEM_OPERATIONS")
//				||query_table.equals("PTEM_FITTING")
//				)
//			{
//				pipesectionno="PIPENO";
//			}
//			
//		    if(main_field.equals("")||foreign_field.equals(""))
//			{
//				//判断是否包含多个
//				String sfieldvalues[]=sfieldvalue.split("\\,");
//				int num=sfieldvalues.length;
//				if(num==1)
//				{
//					strSql="select ";
//					strSql+=pipelieno;
//					strSql+=",";
//					strSql+=query_field+" from "+query_table+" t where t."+
//					condition_field_en+" in('"+sfieldvalue+"')";
//				}
//				else
//				{
//					strSql="select ";
//					strSql+=pipelieno;
//					strSql+=",";
//					strSql+=query_field+" from "+query_table+" t where t."+
//					condition_field_en+" in(";
//					for(int i=0;i<num;i++)
//					{
//						strSql+="'"+sfieldvalues[i]+"',";
//					}	
//					strSql=strSql.substring(0,strSql.length()-1);
//					strSql+=")";
//				}			
//				guanxianlists = dbService.queryDataBySql(strSql);
//				listAll.add(guanxianlists);
//			}
//			else if(connect_field.equals("")||connect_table.equals(""))
//			{
//				//判断是否包含多个
//				String sfieldvalues[]=sfieldvalue.split("\\,");
//				int numValue=sfieldvalues.length;
//				if(numValue==1)
//				{
//					strSql="select t2."+main_field+" from "+condition_table+
//					" t2 where t2."+condition_field_en+" in('"+sfieldvalue+"')";
//				}
//				else
//				{
//					strSql="select t2."+main_field+" from "+condition_table+
//					" t2 where t2."+condition_field_en+" in(";			
//					for(int i=0;i<numValue;i++)
//					{
//						strSql+="'"+sfieldvalues[i]+"',";
//					}	
//					strSql=strSql.substring(0,strSql.length()-1);
//					strSql+=")";
//				}			
//				List<String> list=dbService.queryDataBySql(strSql);
//				int size=list.size();
//				if(size==0)
//				{
//					return null;
//				}
//				List<String> resultList=new ArrayList();
//				for(int i=0;i<size;i++)
//				{
//					if(list.get(i)==null)
//					{
//						continue;
//					}
//					String result=list.get(i);
//					String[] fieldValue=result.split("；");
//					int num=fieldValue.length;
//					for(int j=0;j<num;j++)
//					{
//						String str=fieldValue[j];
//						resultList.add(str);
//					}
//				}			
//				if(resultList.size()==0)
//				{
//					return null;
//				}
//				strSql="select ";
//				strSql+=pipelieno;
//				strSql+=",";
//				strSql+=query_field+" from "+query_table+" t1 where t1."+
//				foreign_field+" in(";
//				int num=resultList.size();
//				for(int k=0;k<num;k++)
//				{
//					strSql+="'"+resultList.get(k)+"',";
//				}
//				strSql=strSql.substring(0,strSql.length()-1);
//				strSql+=")";
//				
//				guanxianlists = dbService.queryDataBySql(strSql);
//				listAll.add(guanxianlists);
//			}
//			else
//			{
//				//判断是否包含多个
//				String sfieldvalues[]=sfieldvalue.split("\\,");
//				int numValue=sfieldvalues.length;
//				if(numValue==1)
//				{
//					strSql="select t2."+main_field+" from "+condition_table+
//					" t2 where t2."+condition_field_en+" in('"+sfieldvalue+"')";
//				}
//				else
//				{
//					strSql="select t2."+main_field+" from "+condition_table+
//					" t2 where t2."+condition_field_en+" in(";			
//					for(int i=0;i<numValue;i++)
//					{
//						strSql+="'"+sfieldvalues[i]+"',";
//					}	
//					strSql=strSql.substring(0,strSql.length()-1);
//					strSql+=")";
//				}			
//				List<String> list=dbService.queryDataBySql(strSql);
//				int size=list.size();
//				if(size==0)
//				{
//					return null;
//				}
//				List<String> resultList=new ArrayList();
//				for(int i=0;i<size;i++)
//				{
//					if(list.get(i)==null)
//					{
//						continue;
//					}
//					String result=list.get(i);
//					String[] fieldValue=result.split("；");
//					int num=fieldValue.length;
//					for(int j=0;j<num;j++)
//					{
//						String str=fieldValue[j];
//						resultList.add(str);
//					}
//				}			
//				if(resultList.size()==0)
//				{
//					return null;
//				}
//				strSql="select ";
//				strSql+=pipelieno;
//				strSql+=",";
//				strSql+=query_field+" from "+query_table+" t1 where t1."+
//				foreign_field+" in(select t2."+connect_field+" from "+connect_table
//				+" t2 where t2."+connect_field_con+" in(";
//					
//				int num=resultList.size();
//				for(int k=0;k<num;k++)
//				{
//					strSql+="'"+resultList.get(k)+"',";
//				}
//				strSql=strSql.substring(0,strSql.length()-1);
//				strSql+=")";
//				strSql+=")";
//				guanxianlists = dbService.queryDataBySql(strSql);
//				listAll.add(guanxianlists);
//			}
//		}
//		
//		return listAll;
//	}
//	public List< List<Object[]> > getListByAutosearchPipePoint() throws IOException{	
//		String owner=getRequest().getParameter("owner");
//		//关键字查询
//		String kfieldname= StringUtil.encodingUrl(getRequest().getParameter("kfieldname"));
//		String kfieldvalue=StringUtil.encodingUrl(getRequest().getParameter("kfieldvalue"));
//	    //kfieldvalue = java.net.URLDecoder.decode(kfieldvalue,"UTF-8");
//		//选择查询
//		String sfieldname=StringUtil.encodingUrl(getRequest().getParameter("sfieldname"));
//		String sfieldvalue=StringUtil.encodingUrl(getRequest().getParameter("sfieldvalue"));			
//		//区间查询
//		String rfieldname=StringUtil.encodingUrl(getRequest().getParameter("rfieldname"));
//		String rfieldvalue1=StringUtil.encodingUrl(getRequest().getParameter("rfieldvalue1"));
//		String rlimit1=StringUtil.encodingUrl(getRequest().getParameter("rlimit1"));
//		String rfieldvalue2=StringUtil.encodingUrl(getRequest().getParameter("rfieldvalue2"));
//		String rlimit2=StringUtil.encodingUrl(getRequest().getParameter("rlimit2"));		
//		//日期查询
//		String dfieldname=StringUtil.encodingUrl(getRequest().getParameter("dfieldname"));
//		String dfieldvalue1=getRequest().getParameter("dfieldvalue1");
//		String dfieldvalue2=getRequest().getParameter("dfieldvalue2");	
//		String searchSql="";
//		List<List <Object[] > > list=new ArrayList();
//		//List<String> guanxianlists=null;
//		//关键字查询
//		if(kfieldname!=""&kfieldvalue!="") 
//		{
//			list=getListByAutosearchKeywordPoint(kfieldname,kfieldvalue,owner);
//		}
//		//选择查询
//		if(sfieldname!=""&sfieldvalue!="") 
//		{		
//			String dictionaryTableName="";
//			int length=sfieldname.length();
//			if(length<9)
//			{
//				dictionaryTableName="PTEM_TYPE_HAS";
//			}
//			else
//			{
//				String temp=sfieldname.substring(0, 9);
//				if(temp.equals("PTEM_TYPE")==false)
//				{
//					dictionaryTableName="PTEM_TYPE_HAS";
//				}
//			}
//			if(dictionaryTableName.equals("PTEM_TYPE_HAS"))
//			{
////				List<List <Object[] > > selList=getListByAutosearchSelectHas(sfieldname,sfieldvalue,owner);
////				if(list==null)
////				{
////					list=selList;
////				}
////				else {
////					list.retainAll(selList);
////				}
//			}
//			else if(dictionaryTableName.equals("PTEM_TYPE_POINT_QUERY")){
//				List<List <Object[] > > selList =getListByAutosearchSelectPointType(sfieldname,sfieldvalue,owner);
//				if(list==null||list.size()==0)
//				{
//					list=selList;
//				}
//				else {
//					list.retainAll(selList);
//				}
//			}
//			else
//			{
//				List<List <Object[] > > selList =getListByAutosearchSelectPoint(sfieldname,sfieldvalue,owner);
//				if(list==null||list.size()==0)
//				{
//					list=selList;
//				}
//				else {
//					list.retainAll(selList);
//				}
//			}
//			
//		}
//		return list;
//	}
	
	

	public Map getListByAutosearchPipePoint() throws IOException{	
		String owner=getRequest().getParameter("owner");
		//关键字查询
		String kfieldname= StringUtil.encodingUrl(getRequest().getParameter("kfieldname"));
		String kfieldvalue=StringUtil.encodingUrl(getRequest().getParameter("kfieldvalue"));
		//选择查询
		String sfieldname=StringUtil.encodingUrl(getRequest().getParameter("sfieldname"));
		String sfieldvalue=StringUtil.encodingUrl(getRequest().getParameter("sfieldvalue"));			
		//区间查询
		String rfieldname=StringUtil.encodingUrl(getRequest().getParameter("rfieldname"));
		String rfieldvalue1=StringUtil.encodingUrl(getRequest().getParameter("rfieldvalue1"));
		String rlimit1=StringUtil.encodingUrl(getRequest().getParameter("rlimit1"));
		String rfieldvalue2=StringUtil.encodingUrl(getRequest().getParameter("rfieldvalue2"));
		String rlimit2=StringUtil.encodingUrl(getRequest().getParameter("rlimit2"));		
		//日期查询
		String dfieldname=StringUtil.encodingUrl(getRequest().getParameter("dfieldname"));
		String dfieldvalue1=getRequest().getParameter("dfieldvalue1");
		String dfieldvalue2=getRequest().getParameter("dfieldvalue2");	
		String searchSql="";
		List<List <Object[] > > list=new ArrayList();
		Map map=new HashMap();
		//List<String> guanxianlists=null;
		//关键字查询
		if(kfieldname!=""&kfieldvalue!="") 
		{
			map=getListByAutosearchKeywordPoint(kfieldname,kfieldvalue,owner);
			//map.put("tee", list);
		}
		//选择查询
		if(sfieldname!=""&sfieldvalue!="") 
		{		
			String dictionaryTableName="";
			int length=sfieldname.length();
			if(length<9)
			{
				dictionaryTableName="PTEM_TYPE_HAS";
			}
			else
			{
				String temp=sfieldname.substring(0, 9);
				if(temp.equals("PTEM_TYPE")==false)
				{
					dictionaryTableName="PTEM_TYPE_HAS";
				}
			}
			if(sfieldname.equals("PTEM_TYPE_HAS"))
			{
				Map selList =getListByAutosearchSelectPointHas(sfieldname,sfieldvalue,owner);
				if(map==null||map.size()==0)
				{
					map=selList;
				}
			}
			else if(sfieldname.equals("PTEM_TYPE_POINT_QUERY")){
				Map selList =getListByAutosearchSelectPointType(sfieldname,sfieldvalue,owner);
				if(map==null||map.size()==0)
				{
					map=selList;
				}
//				else {
//					map.retainAll(selList);
//				}
			}
			else
			{
				Map selList =getListByAutosearchSelectPoint(sfieldname,sfieldvalue,owner);
				if(list==null||list.size()==0)
				{
					map=selList;
				}
//				else {
//					list.retainAll(selList);
//				}
			}			
		}
		
		return map;
	}
	
	public List<String> getListByChaoqi() throws IOException{
		List<String> pipelinelist=new ArrayList();
		//查询即将到期的任务编号
		String sql="select t.taskno from PTEM_TEST_SUMMARY t where " +
				"t.NEXTTESTDATE<sysdate";
		List<String> tasknolist=dbService.queryDataBySql(sql);
		String tasknos="";
		int num=tasknolist.size();
		for(int i=0;i<num;i++)
		{
			tasknos+="'";
			tasknos+=tasknolist.get(i);
			tasknos+="'";
			tasknos+=",";
		}
		if(tasknos.equals(""))
		{
			return pipelinelist;
		}
		tasknos=tasknos.substring(0,tasknos.length()-1);
		//查询任务编号下的管线编、管段编号
		sql="select t.pipelineno,t.pipesectionno from PTEM_TEST_TASK t " +
				"where t.taskno in ("+tasknos+")";
		List<Object[]>list=dbService.queryDataBySql(sql);
		
		num=list.size();
		for(int i=0;i<num;i++)
		{
			if(list.get(i)[0]!=null)
			{
				String pipelinenos=list.get(i)[0].toString();
				if(!pipelinenos.equals(""))
				{
					String pipeline[]=pipelinenos.split("；");
					int numline=pipeline.length;
					for(int j=0;j<numline;j++)
					{
						pipelinelist.add(pipeline[j]);
					}
				}
			}
			if(list.get(i)[1]!=null)
			{
				String pipesectionnos=list.get(i)[1].toString();
				if(!pipesectionnos.equals(""))
				{
					String pipesection[]=pipesectionnos.split("；");
					int numsec=pipesection.length;
					for(int j=0;j<numsec;j++)
					{
						if(pipesection[j].length()==14)
						{
							String pipelineno=pipesection[j].substring(0,9);
							pipelinelist.add(pipelineno);
						}						
					}
				}
			}
		}
		return pipelinelist;
	}
	public List<String> getListByJijiangdaoqi() throws IOException{	
		List<String> pipelinelist=new ArrayList();
		//查询即将到期的任务编号
		String sql="select t.taskno from PTEM_TEST_SUMMARY t where " +
				"t.NEXTTESTDATE<add_months(sysdate,3) and t.NEXTTESTDATE>sysdate";
		List<String> tasknolist=dbService.queryDataBySql(sql);
		String tasknos="";
		int num=tasknolist.size();
		for(int i=0;i<num;i++)
		{
			tasknos+="'";
			tasknos+=tasknolist.get(i);
			tasknos+="'";
			tasknos+=",";
		}	
		if(tasknos.equals(""))
		{
			return pipelinelist;
		}
		tasknos=tasknos.substring(0,tasknos.length()-1);
		//查询任务编号下的管线编、管段编号
		sql="select t.pipelineno,t.pipesectionno from PTEM_TEST_TASK t " +
				"where t.taskno in ("+tasknos+")";
		List<Object[]>list=dbService.queryDataBySql(sql);
		
		num=list.size();
		for(int i=0;i<num;i++)
		{
			if(list.get(i)[0]!=null)
			{
				String pipelinenos=list.get(i)[0].toString();
				if(!pipelinenos.equals(""))
				{
					String pipeline[]=pipelinenos.split("；");
					int numline=pipeline.length;
					for(int j=0;j<numline;j++)
					{
						pipelinelist.add(pipeline[j]);
					}
				}
			}
			if(list.get(i)[1]!=null)
			{
				String pipesectionnos=list.get(i)[1].toString();
				if(!pipesectionnos.equals(""))
				{
					String pipesection[]=pipesectionnos.split("；");
					int numsec=pipesection.length;
					for(int j=0;j<numsec;j++)
					{
						if(pipesection[j].length()==14)
						{
							String pipelineno=pipesection[j].substring(0,9);
							pipelinelist.add(pipelineno);
						}						
					}
				}
			}
		}
		return pipelinelist;
	}
	public List<String> getListByAutosearch() throws IOException{	
		String owner=getRequest().getParameter("owner");
		//关键字查询
		String kfieldname= StringUtil.encodingUrl(getRequest().getParameter("kfieldname"));
		String kfieldvalue=StringUtil.encodingUrl(getRequest().getParameter("kfieldvalue"));
	    //kfieldvalue = java.net.URLDecoder.decode(kfieldvalue,"UTF-8");
		//选择查询
		String sfieldname=StringUtil.encodingUrl(getRequest().getParameter("sfieldname"));
		String sfieldvalue=StringUtil.encodingUrl(getRequest().getParameter("sfieldvalue"));			
		//区间查询
		String rfieldname=StringUtil.encodingUrl(getRequest().getParameter("rfieldname"));
		String rfieldvalue1=StringUtil.encodingUrl(getRequest().getParameter("rfieldvalue1"));
		String rlimit1=StringUtil.encodingUrl(getRequest().getParameter("rlimit1"));
		String rfieldvalue2=StringUtil.encodingUrl(getRequest().getParameter("rfieldvalue2"));
		String rlimit2=StringUtil.encodingUrl(getRequest().getParameter("rlimit2"));		
		//日期查询
		String dfieldname=StringUtil.encodingUrl(getRequest().getParameter("dfieldname"));
		String dfieldvalue1=getRequest().getParameter("dfieldvalue1");
		String dfieldvalue2=getRequest().getParameter("dfieldvalue2");	
		String searchSql="";
		List<String> guanxianlists=null;
		//关键字查询
		if(kfieldname!=""&kfieldvalue!="") 
		{
			guanxianlists=getListByAutosearchKeyword(kfieldname,kfieldvalue,owner);
		}
		//选择查询
		if(sfieldname!=""&sfieldvalue!="") 
		{		
			String dictionaryTableName="";
			int length=sfieldname.length();
			if(length<9)
			{
				dictionaryTableName="PTEM_TYPE_HAS";
			}
			else
			{
				String temp=sfieldname.substring(0, 9);
				if(temp.equals("PTEM_TYPE")==false)
				{
					dictionaryTableName="PTEM_TYPE_HAS";
				}
			}
			if(dictionaryTableName.equals("PTEM_TYPE_HAS"))
			{
				List<String> selList=getListByAutosearchSelectHas(sfieldname,sfieldvalue,owner);
				if(guanxianlists==null)
				{
					guanxianlists=selList;
				}
				else {
					guanxianlists.retainAll(selList);
				}
			}
			else
			{
				List<String> selList=getListByAutosearchSelect(sfieldname,sfieldvalue,owner);
				if(guanxianlists==null)
				{
					guanxianlists=selList;
				}
				else {
					guanxianlists.retainAll(selList);
				}
			}
			
		}
		//区间查询
		if(rfieldname!=""&((rfieldvalue1!=""&&rlimit1!="")||(rfieldvalue2!=""&&rlimit2!="")))
		{
			List<String> rList=new ArrayList();
			if(owner.equals("TaskSearch"))
			{
				rList=getListByAutosearchRange(rfieldname,rfieldvalue1,rlimit1,
						rfieldvalue2,rlimit2,owner);
			}
			else
			{
				rList=getListByAutosearchRangeMulti(rfieldname,rfieldvalue1,rlimit1,
						rfieldvalue2,rlimit2,owner);
			}
			
			if(guanxianlists==null)
			{
				guanxianlists=rList;
			}
			else {
				guanxianlists.retainAll(rList);
			}
		}
		//日期查询
		if(dfieldname!=""&(dfieldvalue1!=""&dfieldvalue2!="")) 
		{		
			List<String> dList=getListByAutosearchDate(dfieldname,dfieldvalue1,dfieldvalue2,owner);
			if(guanxianlists==null)
			{
				guanxianlists=dList;
			}
			else {
				guanxianlists.retainAll(dList);
			}
		}
		return guanxianlists;
	}
	
	
	
	public void queryPipeLineList()
	{
		//String kfieldvalue = getRequest().getParameter("kfieldvalue");
		String pipelinenos=getRequest().getParameter("pipelinenos");
		Map<String,String> filterMap=getPagerMap();
		if(null!=pipelinenos && !"".equals(pipelinenos)){
			filterMap.put("pipelinenos", pipelinenos);
		}
		PageResult result= guanxianService.queryPipeLineList(filterMap);
		String[] viewArray={
				"ID","PIPELINENO","PROJECTNO","DOCUMENTNO","PROJECTNAME","MEDIA","PRESSURELEVEL",
				"TSGPRESSURELEVEL","MANAGESTYLE","MANAGEUNIT","MANAGEDEPARTMENT","PIPETYPE",
				"PAVEMODE","MATERIAL","MATERIALMARK","DIAMETER","OUTERDIAMETER",
				"THICKNESS","LENGTH","DESIGNPRESSURE","DESIGNTEMPERATURE","COATINGTYPE",
				"COATINGLEVEL","CPTYPE","SIGNEDUNIT","SIGNED","REMARK"
			}
		;
		String str=getColumnJson(result,viewArray);
		HttpServletResponse response = ServletActionContext.getResponse();
		response.setContentType("application/XML,charset=GBK");
		response.setHeader("Charset", "GBK");
		response.setCharacterEncoding("GBK");
		response.setContentType("text/xml");
		PrintWriter out;
		try {
			out = getResponse().getWriter();
			out.print(str);
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	
	public List<String> getGuanxianList()
	{
		//关键字查询
		String kfieldname= getRequest().getParameter("kfieldname");
		//kfieldname="PIPELINENO";
		String kfieldvalue=getRequest().getParameter("kfieldvalue");
	    //kfieldvalue = java.net.URLDecoder.decode(kfieldvalue,"UTF-8");
		//kfieldvalue="020010134";
		//选择查询
		String sfieldname=getRequest().getParameter("sfieldname");
		String sfieldvalue=getRequest().getParameter("sfieldvalue");			
		//区间查询
		String rfieldname=getRequest().getParameter("rfieldname");
		String rfieldvalue1=getRequest().getParameter("rfieldvalue1");
		String rlimit1=getRequest().getParameter("rlimit1");
		String rfieldvalue2=getRequest().getParameter("rfieldvalue2");
		String rlimit2=getRequest().getParameter("rlimit2");		
		//日期查询
		String dfieldname=getRequest().getParameter("dfieldname");
		String dfieldvalue1=getRequest().getParameter("dfieldvalue1");
		String dfieldvalue2=getRequest().getParameter("dfieldvalue2");	
		String searchSql="";
		List<String> guanxianlists=null;
		//关键字查询
		if(kfieldname!=""&kfieldvalue!="") 
		{
			String strSql = "select t.searchsource from ptem_fieldname1 t where t.fieldname='"+kfieldname+"'";
			List<String> lserchtable=dbService.queryDataBySql(strSql);
			String searchtable=lserchtable.get(0).toString();			
			strSql="select distinct t.pipelineno from "+searchtable+" t where t."+kfieldname+"='"+kfieldvalue+"'";
			searchSql=strSql;
			guanxianlists = dbService.queryDataBySql(searchSql);
			if(searchtable.equals("PTEM_TEST_TASK")) //表1 检验检测任务表中的一条记录的多个管线以“；”分隔。
			{
				guanxianlists=splitPipeLine(guanxianlists);
			}
		}
		//选择查询
		if(sfieldname!=""&sfieldvalue!="") 
		{			
			String strSql = "select t.searchsource from ptem_tablename t where t.tablename='"+sfieldname+"'";
			List lserchtable=dbService.queryDataBySql(strSql);
			String searchtable=lserchtable.get(0).toString();						
			strSql = "select t.wordname from ptem_tablename t where t.tablename='"+sfieldname+"'";
			lserchtable=dbService.queryDataBySql(strSql);
			String searchword=lserchtable.get(0).toString();						
			String[] index= sfieldvalue.split(",");
			String sserachzidian="";
			List szidian;
			for(int i=0;i<(index.length);i++)
			{
				strSql = "select t.typename from "+sfieldname+" t where t.typeindex='" +index[i]+"'";
				 szidian=dbService.queryDataBySql(strSql);	
				 if(i==(index.length)-1)
				 {
					 sserachzidian+=szidian.get(0).toString()+"'";
				 }
				 else{
					 sserachzidian+=szidian.get(0).toString()+"'"+" or t."+searchword+"='";		
				 }							
			}	
			String	searchstrSql="select t.pipelineno  from "+searchtable+" t where t."+searchword+"='"+sserachzidian;
			searchSql=searchstrSql;
			List guanxianlistSelect = dbService.queryDataBySql(searchSql);
			if(searchtable.equals("PTEM_TEST_TASK")) //表1 检验检测任务表中的一条记录的多个管线以“；”分隔。
			{
				guanxianlistSelect=splitPipeLine(guanxianlistSelect);
			}
			if(guanxianlists==null)
			{
				guanxianlists=guanxianlistSelect;
			}
			else {
				guanxianlists.retainAll(guanxianlistSelect);
			}
		}
		//区间查询
		if(rfieldname!=""&((rfieldvalue1!=""&&rlimit1!="")||(rfieldvalue2!=""&&rlimit2!="")))
		{
			
			String strSql = "select t.searchsource from ptem_fieldname3 t where t.fieldname='"+rfieldname+"'";
			List lserchtable=dbService.queryDataBySql(strSql);
			String searchtable=lserchtable.get(0).toString();					
			if((rfieldvalue1!=""&rlimit1!="")&(rfieldvalue2!=""&rlimit2!=""))
			{
				strSql="select t.pipelineno from "+searchtable+" t where t."+rfieldname+rlimit1 +"'"+rfieldvalue1+"'" +" and t."+rfieldname+rlimit2 +"'"+rfieldvalue2+"'";
			}
			else if(rfieldvalue1!=""&rlimit1!="")
			{
				strSql="select t.pipelineno from "+searchtable+" t where t."+rfieldname+rlimit1+"'"+ rfieldvalue1+"'";

			}
			else if(rfieldvalue2!=""&rlimit2!="")
			{
				strSql="select t.pipelineno from "+searchtable+" t where t."+rfieldname+rlimit2+"'"+ rfieldvalue2+"'";

			}			
			searchSql=strSql;
			List guanxianlistRange = dbService.queryDataBySql(searchSql);
			if(searchtable.equals("PTEM_TEST_TASK")) //表1 检验检测任务表中的一条记录的多个管线以“；”分隔。
			{
				guanxianlistRange=splitPipeLine(guanxianlistRange);
			}
			if(guanxianlists==null)
			{
				guanxianlists=guanxianlistRange;
			}
			else {
				guanxianlists.retainAll(guanxianlistRange);
			}
		}
		//日期查询
		if(dfieldname!=""&(dfieldvalue1!=""&dfieldvalue2!="")) 
		{				
			String strSql = "select t.searchsource,t.FIELDNAME," +
					"t.FIELDNAMEMAIN,t.FIELDNAMEFOREIGN,t.FIELDNAMEDES," +
					"t.searchsource2 from ptem_datesearch t " +
					"where t.fieldname='"+dfieldname+"'";
			List lserchtable=dbService.queryDataBySql(strSql);
			Object[] obj=new Object[6];
			obj=(Object [])lserchtable.get(0);
			String searchtable=(String)obj[0].toString();
			String fieldNameQuery=obj[1].toString();
			String fieldNameMain=obj[2].toString();
			String fieldNameForeign=obj[3].toString();
			String fieldNameDes=obj[4].toString();
			String searchtable2=obj[5].toString();
			String strSQL;
			strSQL="select t."+fieldNameDes+" from "+searchtable2+" t where t."+
			fieldNameForeign+" in (select t1."+fieldNameMain+" from "+searchtable
			+" t1 where t1."+fieldNameQuery+" between to_date('"+ dfieldvalue1+
			"','YYYY/MM/DD') and to_date('"+dfieldvalue2+"','YYYY/MM/DD'))";								
			searchSql=strSQL;
			List guanxianlistDate = dbService.queryDataBySql(searchSql);
			if(searchtable.equals("PTEM_TEST_TASK")) //表1 检验检测任务表中的一条记录的多个管线以“；”分隔。
			{
				guanxianlistDate=splitPipeLine(guanxianlistDate);
			}
			if(guanxianlists==null)
			{
				guanxianlists=guanxianlistDate;
			}
			else {
				guanxianlists.retainAll(guanxianlistDate);
			}
		}
		return guanxianlists;
	}
	//获取管线坐标
	public void getCoordinate()throws IOException{	
		List<String> guanxianlists = getListByAutosearch();			
		String strSql;
		JSONObject jsonguanduancx = new JSONObject();
		JSONArray jsonArray = new JSONArray();
		if(guanxianlists==null||guanxianlists.size()==0)
		{
			return;
		}
		String pipelinenos="";
		for(int i=0;i<guanxianlists.size();i++){	
			//组合管线编号
			//pipelinenos+="'";
			pipelinenos+=guanxianlists.get(i);
			//pipelinenos+="'";
			pipelinenos+=",";
			//查询管段经纬度
//			strSql = "select t.beginnodel,t.beginnodeb,t.endnodel,t.endnodeb,t.pipesectionno " +
//			"from ptem_pipesection t where t.PIPELINENO='"+guanxianlists.get(i).toString()+"' " ;
			
			strSql = "select t.beginnodel_map,t.beginnodeb_map,t.endnodel_map,t.endnodeb_map,t.pipesectionno " +
			"from ptem_pipesection t where t.PIPELINENO='"+guanxianlists.get(i).toString()+"' " ;
			
			List guanduanList = dbService.queryDataBySql(strSql);
			for(int j=0;j<guanduanList.size();j++){
				Object[] objs = (Object[])guanduanList.get(j);
				JSONObject jsonobj = new JSONObject();
				jsonobj.put("beginnodel", objs[0]==null?"":objs[0].toString());
				jsonobj.put("beginnodeb", objs[1]==null?"":objs[1].toString());
				jsonobj.put("endnodel", objs[2]==null?"":objs[2].toString());
				jsonobj.put("endnodeb", objs[3]==null?"":objs[3].toString());
				jsonobj.put("pipesectionno", objs[4]==null?"":objs[4].toString());
				//表5-7 不同管线编号根据绝缘电阻值评定等级以不同颜色显示
				String pipesectionno=objs[4].toString();
				String pipelineno=pipesectionno.substring(0,9);
				String colorlevelRiso=getColorlevelRiso(pipelineno,pipesectionno);
				jsonobj.put("colorlevelRiso", colorlevelRiso);
				//表5-10 不同管线编号根据管地电位范围以不同颜色显示 850~1200绿色 >1200黄色 <850红色
				String colorlevelPotential=getColorlevelPotential(pipelineno,pipesectionno);
				jsonobj.put("colorlevelPotential", colorlevelPotential);
				jsonArray.add(jsonobj);
			}
		}
		jsonguanduancx.put("guanduandata", jsonArray);
		pipelinenos=pipelinenos.substring(0,pipelinenos.length()-1);
		jsonguanduancx.put("pipelinenos", pipelinenos);
		getSession().setAttribute("pipelinenos", pipelinenos);
		PrintWriter out = getResponse().getWriter();
		out.print(jsonguanduancx.toString());		
	}
	//获取多条任务下的管线
	public List<String> getTaskPipeLinesAll(List<String> tasklists)throws IOException{
		List<String> guanxianlists=new ArrayList();
		int num=tasklists.size();
		String tasknos="";
		for(int i=0;i<num;i++)
		{
			tasknos+="'";
			String taskno=tasklists.get(i);
			tasknos+=taskno;
			tasknos+="'";
			tasknos+=",";
		}
		tasknos=tasknos.substring(0,tasknos.length()-1);
		String sql="select t.pipelineno from ptem_test_task t where t.taskno in (";
		sql+=tasknos;
		sql+=")";
		List<String> pipelinelists=dbService.queryDataBySql(sql);
		num=pipelinelists.size();
		
		for(int i=0;i<num;i++)
		{
			if(pipelinelists.get(i)==null){
				continue;
			}
			String piplinenos=pipelinelists.get(i);
			String piplineno[]=piplinenos.split("；");
			int size=piplineno.length;
			for(int j=0;j<size;j++)
			{
				guanxianlists.add(piplineno[j]);
			}
		}
		return guanxianlists;
	}
	//获取一条任务下的站箱
	public List<String> getTaskStations(String taskno)throws IOException{
		List<String> zhanxianglists=new ArrayList();
		
		String sql="select t1.stationname from PTEM_STATION t1,PTEM_TEST_TASK t2 " +
				"where t1.PIPENO=t2.ZHXPIPESECTIONNO and t2.taskno ='";
		sql+=taskno;
		sql+="'";
		List<String> stationnames=dbService.queryDataBySql(sql);
		int num=stationnames.size();
		
		for(int i=0;i<num;i++)
		{
			String stationname=stationnames.get(i);
			if(stationname==null)
			{
				continue;
			}
			String stationnamearr[]=stationname.split("；");
			int size=stationnamearr.length;
			for(int j=0;j<size;j++)
			{
				zhanxianglists.add(stationnamearr[j]);
			}
		}
		return zhanxianglists;
	}
	//获取一条任务下的管线
	public List<String> getTaskPipeLines(String taskno)throws IOException{
		List<String> guanxianlists=new ArrayList();
		
		String sql="select t.pipelineno from ptem_test_task t where t.taskno ='";
		sql+=taskno;
		sql+="'";
		List<String> pipelinelists=dbService.queryDataBySql(sql);
		int num=pipelinelists.size();
		
		for(int i=0;i<num;i++)
		{
			String piplinenos=pipelinelists.get(i);
			if(piplinenos==null)
			{
				continue;
			}
			String piplineno[]=piplinenos.split("；");
			int size=piplineno.length;
			for(int j=0;j<size;j++)
			{
				guanxianlists.add(piplineno[j]);
			}
		}
		return guanxianlists;
	}
	
	//获取一条任务下的管段
	public List<String> getTaskPipeSections(String taskno)throws IOException{
		List<String> guanxianlists=new ArrayList();
		
		String sql="select t.pipesectionno from ptem_test_task t where t.taskno ='";
		sql+=taskno;
		sql+="'";
		List<Object> pipelinelists=dbService.queryDataBySql(sql);
		if(pipelinelists==null)
		{
			return null;
		}
		int num=pipelinelists.size();
		
		for(int i=0;i<num;i++)
		{    
			Object obj=pipelinelists.get(i);
			if(obj==null)
			{
				continue;
			}
			String piplinenos=obj.toString();
			String piplineno[]=piplinenos.split("；");
			int size=piplineno.length;
			for(int j=0;j<size;j++)
			{
				guanxianlists.add(piplineno[j]);
			}
		}
		return guanxianlists;
	}
	
	//获取任务下的管线管段
	public void getCoordinateTask()throws IOException{	
		List<String> tasklists = getListByAutosearch();
		if(tasklists==null||tasklists.size()==0)
		{
			return;
		}
		List<String> guanxianlists=getTaskPipeLinesAll(tasklists);
		if(guanxianlists==null||guanxianlists.size()==0)
		{
			return;
		}
		String strSql;
		JSONObject jsonguanduancx = new JSONObject();
		JSONArray jsonArray = new JSONArray();
		for(int i=0;i<guanxianlists.size();i++){	
			//查询管段经纬度
//			strSql = "select t.beginnodel,t.beginnodeb,t.endnodel,t.endnodeb,t.pipesectionno " +
//			"from ptem_pipesection t where t.PIPELINENO='"+guanxianlists.get(i).toString()+"' " ;
			
			strSql = "select t.beginnodel_map,t.beginnodeb_map,t.endnodel_map,t.endnodeb_map,t.pipesectionno " +
			"from ptem_pipesection t where t.PIPELINENO='"+guanxianlists.get(i).toString()+"' " ;
			
			List guanduanList = dbService.queryDataBySql(strSql);
			for(int j=0;j<guanduanList.size();j++){
				Object[] objs = (Object[])guanduanList.get(j);
				JSONObject jsonobj = new JSONObject();
				jsonobj.put("beginnodel", objs[0]==null?"":objs[0].toString());
				jsonobj.put("beginnodeb", objs[1]==null?"":objs[1].toString());
				jsonobj.put("endnodel", objs[2]==null?"":objs[2].toString());
				jsonobj.put("endnodeb", objs[3]==null?"":objs[3].toString());
				jsonobj.put("pipesectionno", objs[4]==null?"":objs[4].toString());
				
				//表5-7 不同管线编号根据绝缘电阻值评定等级以不同颜色显示
				String pipesectionno=objs[4].toString();
				String pipelineno=pipesectionno.substring(0,9);
				String colorlevelRiso=getColorlevelRiso(pipelineno,pipesectionno);
				jsonobj.put("colorlevelRiso", colorlevelRiso);
				//表5-10 不同管线编号根据管地电位范围以不同颜色显示 850~1200绿色 >1200黄色 <850红色
				String colorlevelPotential=getColorlevelPotential(pipelineno,pipesectionno);
				jsonobj.put("colorlevelPotential", colorlevelPotential);
				jsonArray.add(jsonobj);
			}
		}
		jsonguanduancx.put("guanduandata", jsonArray);
		int num=tasklists.size();
		String tasknos="";
		for(int j=0;j<num;j++)
		{
			tasknos+=tasklists.get(j);
			tasknos+=",";
		}
		tasknos=tasknos.substring(0,tasknos.length()-1);
		//jsonguanduancx.put("pipelinenos", pipelinenos);
		getSession().setAttribute("tasknos", tasknos);
		PrintWriter out = getResponse().getWriter();
		out.print(jsonguanduancx.toString());		
	}
	
	public void getCoordinatePipeSection()throws IOException{	
		List<String> guanduanlists = getListByAutosearch();	
		if(guanduanlists==null||guanduanlists.size()==0)
		{
			return;
		}
		String strSql;
		JSONObject jsonguanduancx = new JSONObject();
		JSONArray jsonArray = new JSONArray();
		
		String pipesectionnos="";
		for(int i=0;i<guanduanlists.size();i++){	
			//组合管线编号
			//pipelinenos+="'";
			pipesectionnos+=guanduanlists.get(i);
			//pipelinenos+="'";
			pipesectionnos+=",";
			//查询管段经纬度
			//strSql = "select t.beginnodel,t.beginnodeb,t.endnodel,t.endnodeb,t.pipesectionno " +
			//"from ptem_pipesection t where t.PIPESECTIONNO='"+guanduanlists.get(i).toString()+"' " ;
			strSql = "select t.beginnodel_map,t.beginnodeb_map,t.endnodel_map,t.endnodeb_map,t.pipesectionno " +
			"from ptem_pipesection t where t.PIPESECTIONNO='"+guanduanlists.get(i).toString()+"' " ;
			
			List guanduanList = dbService.queryDataBySql(strSql);
			for(int j=0;j<guanduanList.size();j++){
				Object[] objs = (Object[])guanduanList.get(j);
				JSONObject jsonobj = new JSONObject();
				jsonobj.put("beginnodel", objs[0]==null?"":objs[0].toString());
				jsonobj.put("beginnodeb", objs[1]==null?"":objs[1].toString());
				jsonobj.put("endnodel", objs[2]==null?"":objs[2].toString());
				jsonobj.put("endnodeb", objs[3]==null?"":objs[3].toString());
				jsonobj.put("pipesectionno", objs[4]==null?"":objs[4].toString());
				//表5-7 不同管线编号根据绝缘电阻值评定等级以不同颜色显示
				String pipesectionno=objs[4].toString();
				String pipelineno=pipesectionno.substring(0,9);
				String colorlevelRiso=getColorlevelRiso(pipelineno,pipesectionno);
				jsonobj.put("colorlevelRiso", colorlevelRiso);
				//表5-10 不同管线编号根据管地电位范围以不同颜色显示 850~1200绿色 >1200黄色 <850红色
				String colorlevelPotential=getColorlevelPotential(pipelineno,pipesectionno);
				jsonobj.put("colorlevelPotential", colorlevelPotential);
				jsonArray.add(jsonobj);
			}
		}
		jsonguanduancx.put("guanduandata", jsonArray);
		if(pipesectionnos.length()>0)
		{
			pipesectionnos=pipesectionnos.substring(0,pipesectionnos.length()-1);
		}
		
		//jsonguanduancx.put("pipelinenos", pipesectionnos);
		getSession().setAttribute("pipesectionnos", pipesectionnos);
		PrintWriter out = getResponse().getWriter();
		out.print(jsonguanduancx.toString());		
	}
	
	public void getCoordinatePipePoint()throws IOException{	
		Map lists = getListByAutosearchPipePoint();		
		if(lists==null||lists.size()==0)
		{
			return;
		}
		int num=lists.size();
		
		List<String> listnos=new ArrayList();
//		for(int i=0;i<num;i++)
//		{
//			String strnos="";
//			List<Object[]> nos=lists.get(i);
//			if(nos==null||nos.size()==0)
//			{
//				continue;
//			}
//			int nonum=nos.size();
//			for(int j=0;j<nonum;j++)
//			{
//				//String no=nos.get(j);
//				//strnos+=no;
//			}
//			listnos.add(strnos);
//		}
		String strSql;
		JSONObject jsonguanduancx = new JSONObject();
		JSONArray jsonArray = new JSONArray();
		String pipesectionnos="";
//		getSession().setAttribute("pipepointnos", listnos.get(0));
//		getSession().setAttribute("pipepointteenos", listnos.get(1));
//		getSession().setAttribute("pipepointanodenos", listnos.get(2));
		
		PrintWriter out = getResponse().getWriter();
		out.print(jsonguanduancx.toString());		
	}
	
	public void getGuanxianListByguanduansearch() throws IOException{			
			List<String> guanxianlists = getGuanxianList();			
			String strSql;
			JSONObject jsonguanduancx = new JSONObject();
			JSONArray jsonArray = new JSONArray();
			for(int i=0;i<guanxianlists.size();i++){							
				strSql = "select t.beginnodel,t.beginnodeb,t.endnodel,t.endnodeb,t.pipesectionno " +
				"from ptem_pipesection t where t.PIPELINENO='"+guanxianlists.get(i).toString()+"' " ;
				List guanduanList = dbService.queryDataBySql(strSql);
				for(int j=0;j<guanduanList.size();j++){
					Object[] objs = (Object[])guanduanList.get(j);
					JSONObject jsonobj = new JSONObject();
					jsonobj.put("beginnodel", objs[0]==null?"":objs[0].toString());
					jsonobj.put("beginnodeb", objs[1]==null?"":objs[1].toString());
					jsonobj.put("endnodel", objs[2]==null?"":objs[2].toString());
					jsonobj.put("endnodeb", objs[3]==null?"":objs[3].toString());
					jsonobj.put("pipesectionno", objs[4]==null?"":objs[4].toString());
					jsonArray.add(jsonobj);
				}
			}
			jsonguanduancx.put("guanduandata", jsonArray);
			PrintWriter out = getResponse().getWriter();
			out.print(jsonguanduancx.toString());					
		}
	public JSONArray getGuanduanLB(List<String> guanxianlists) throws IOException{
		JSONArray jsonArray = new JSONArray();
		for(int i=0;i<guanxianlists.size();i++){	
			
			String strSql = "select t.beginnodel_map,t.beginnodeb_map,t.endnodel_map,t.endnodeb_map,t.pipesectionno " +
			"from ptem_pipesection t where t.PIPELINENO='"+guanxianlists.get(i).toString()+"' " ;
			
			List guanduanList = dbService.queryDataBySql(strSql);
			for(int j=0;j<guanduanList.size();j++){
				Object[] objs = (Object[])guanduanList.get(j);
				JSONObject jsonobj = new JSONObject();
				jsonobj.put("beginnodel", objs[0]==null?"":objs[0].toString());
				jsonobj.put("beginnodeb", objs[1]==null?"":objs[1].toString());
				jsonobj.put("endnodel", objs[2]==null?"":objs[2].toString());
				jsonobj.put("endnodeb", objs[3]==null?"":objs[3].toString());
				jsonobj.put("pipesectionno", objs[4]==null?"":objs[4].toString());
				jsonArray.add(jsonobj);
			}
		}
		return jsonArray;
	}
//	public void getGuanxianTreeByDaojian() throws IOException{
//		List<String> guanxianlists = getListByJijiangdaoqi();
//		//
////		JSONObject jsonguanduancx = new JSONObject();
////		JSONArray jsonArray1 = new JSONArray();
////		jsonArray1=getGuanduanLB(guanxianlists);
////		jsonguanduancx.put("guanduandata", jsonArray1);
//		//PrintWriter out = getResponse().getWriter();
//		//out.print(jsonguanduancx.toString());		
//		//		
//		PrintWriter out=PubMethod.GetPrintWriter();
//		JSONArray jsonArray = new JSONArray();	
//		JSONObject guanwangroot = new JSONObject();
//		guanwangroot.put("id", "root");
//		guanwangroot.put("pId", "-1");
//		guanwangroot.put("name", "北京管网");
//		guanwangroot.put("isParent", true);
//		guanwangroot.put("open", true);
//		jsonArray.add(guanwangroot);
//		JSONObject guanxianroot = new JSONObject();
//		guanxianroot.put("id", "guanxianroot");
//		guanxianroot.put("pId", "root");
//		guanxianroot.put("name", "管线");
//		guanwangroot.put("isParent", true);
//		jsonArray.add(guanxianroot);
//		String strSql;
//		for(int i=0;i<guanxianlists.size();i++){
//			JSONObject guanxian = new JSONObject();
//			guanxian.put("id", "gx"+guanxianlists.get(i).toString());
//			guanxian.put("pId", "guanxianroot");
//			guanxian.put("name", guanxianlists.get(i).toString());
//			jsonArray.add(guanxian);
//			
//			JSONObject guanduanroot = new JSONObject();
//			guanduanroot.put("id", "gdroot"+guanxianlists.get(i).toString());
//			guanduanroot.put("pId", "gx"+guanxianlists.get(i).toString());
//			guanduanroot.put("name", "管段");
//			guanduanroot.put("isParent", true);
//			jsonArray.add(guanduanroot);
//			
//			strSql = "select t.pipesectionno from ptem_pipesection t where " +
//					"t.PIPELINENO='"+guanxianlists.get(i).toString()+"' " ;
//			List guanduanList = dbService.queryDataBySql(strSql);
//			for(int j=0;j<guanduanList.size();j++){
//				JSONObject guanduan = new JSONObject();
//				guanduan.put("id", "gd"+guanduanList.get(j)==null?"":guanduanList.get(j).toString());
//				guanduan.put("pId", "gdroot"+guanxianlists.get(i).toString());
//				guanduan.put("name", guanduanList.get(j)==null?"":guanduanList.get(j).toString());
//				guanduan.put("isParent", false);
//				jsonArray.add(guanduan);
//			}
//		}
//		out.print(jsonArray.toString());
//	}
	public void getGuanxianTreeByDaojian() throws IOException{
		String type=getRequest().getParameter("type");
		List<String> guanxianlists=new ArrayList();
		String rootname="";
		if(type.equals("jijiangdaoqi"))
		{
			guanxianlists= getListByJijiangdaoqi();	
			rootname="即将到期查询结果";
		}
		else 
		{
			guanxianlists= getListByChaoqi();	
			rootname="超期查询结果";
		}
		PrintWriter out=PubMethod.GetPrintWriter();
		JSONObject jsonguanduancx = new JSONObject();
		if(guanxianlists.size()!=0)
		{
			JSONArray jsonArrayguanduan = getGuanduanLB(guanxianlists);
			jsonguanduancx.put("guanduandata", jsonArrayguanduan);
		}
		JSONArray jsonArray = new JSONArray();	
		JSONObject guanwangroot = new JSONObject();
		guanwangroot.put("id", "root");
		guanwangroot.put("pId", "-1");
		//guanwangroot.put("name", "北京管网");
		guanwangroot.put("name", rootname);
		guanwangroot.put("isParent", true);
		guanwangroot.put("open", true);
		jsonArray.add(guanwangroot);
		JSONObject guanxianroot = new JSONObject();
		//guanxianroot.put("id", "guanxianroot");
		guanxianroot.put("id", "guanxianrootR");
		guanxianroot.put("pId", "root");
		guanxianroot.put("name", "管线");
		guanwangroot.put("isParent", true);
		jsonArray.add(guanxianroot);
		String strSql;
		for(int i=0;i<guanxianlists.size();i++){
			String pipelineno=guanxianlists.get(i).toString();
			JSONObject guanxian = new JSONObject();
			guanxian.put("id", "gx"+guanxianlists.get(i).toString());
			//guanxian.put("pId", "guanxianroot");
			guanxian.put("pId", "guanxianrootR");
			guanxian.put("name", guanxianlists.get(i).toString());
			jsonArray.add(guanxian);
			
			JSONObject guanduanroot = new JSONObject();
			guanduanroot.put("id", "gdroot"+guanxianlists.get(i).toString());
			guanduanroot.put("pId", "gx"+guanxianlists.get(i).toString());
			guanduanroot.put("name", "管段");
			guanduanroot.put("isParent", true);
			jsonArray.add(guanduanroot);
			
			strSql = "select t.pipesectionno from ptem_pipesection t where " +
					"t.PIPELINENO='"+guanxianlists.get(i).toString()+"' " ;
			List guanduanList = dbService.queryDataBySql(strSql);
			for(int j=0;j<guanduanList.size();j++){
				JSONObject guanduan = new JSONObject();
				String id="";
				if(guanduanList.get(j)!=null)
				{
					id="gd"+guanduanList.get(j);
				}
				guanduan.put("id",id);
				//guanduan.put("id", "gd"+guanduanList.get(j)==null?"":guanduanList.get(j).toString());
				guanduan.put("pId", "gdroot"+guanxianlists.get(i).toString());
				guanduan.put("name", guanduanList.get(j)==null?"":guanduanList.get(j).toString());
				guanduan.put("isParent", false);
				jsonArray.add(guanduan);
			}
			//阀门根节点
			JSONObject valveRoot = GenerateNode("valveRoot"+pipelineno,"gx"+pipelineno,"阀门",true);
			jsonArray.add(valveRoot);
			JSONArray jsonArray1=getValveNode("valveRoot"+pipelineno);	
			for(int j=0;j<jsonArray1.size();j++){
				jsonArray.add(jsonArray1.get(j));
			}
		}	
		jsonguanduancx.put("treedata", jsonArray);
		out.print(jsonguanduancx.toString());
		//out.print(jsonArray.toString());
	}
	public void getGuanxianTreeByAutosearch() throws IOException{
		List<String> guanxianlists = getListByAutosearch();		
		PrintWriter out=PubMethod.GetPrintWriter();
		JSONArray jsonArray = new JSONArray();	
		JSONObject guanwangroot = new JSONObject();		
		guanwangroot.put("id", "root");
		guanwangroot.put("pId", "-1");
		//guanwangroot.put("name", "北京管网");
		guanwangroot.put("name", "管线查询结果");
		guanwangroot.put("isParent", true);
		guanwangroot.put("open", true);
		jsonArray.add(guanwangroot);
		JSONObject guanxianroot = new JSONObject();
		//guanxianroot.put("id", "guanxianroot");
		guanxianroot.put("id", "guanxianrootR");
		guanxianroot.put("pId", "root");
		guanxianroot.put("name", "管线");
		guanwangroot.put("isParent", true);
		jsonArray.add(guanxianroot);
		String strSql;
		for(int i=0;i<guanxianlists.size();i++){
			String pipeLineNO=guanxianlists.get(i).toString();
			JSONObject guanxian = new JSONObject();
			guanxian.put("id", "gx"+guanxianlists.get(i).toString());
			//guanxian.put("pId", "guanxianroot");
			guanxian.put("pId", "guanxianrootR");
			guanxian.put("name", guanxianlists.get(i).toString());
			jsonArray.add(guanxian);
			//管段节点
			JSONObject guanduanroot = new JSONObject();
			guanduanroot.put("id", "gdroot"+guanxianlists.get(i).toString());
			guanduanroot.put("pId", "gx"+guanxianlists.get(i).toString());
			guanduanroot.put("name", "管段");
			guanduanroot.put("isParent", true);
			jsonArray.add(guanduanroot);
			
			strSql = "select t.pipesectionno from ptem_pipesection t where " +
					"t.PIPELINENO='"+guanxianlists.get(i).toString()+"' " ;
			List guanduanList = dbService.queryDataBySql(strSql);
			for(int j=0;j<guanduanList.size();j++){
				JSONObject guanduan = new JSONObject();
				guanduan.put("id", "gd"+guanduanList.get(j)==null?"":guanduanList.get(j).toString());
				guanduan.put("pId", "gdroot"+guanxianlists.get(i).toString());
				guanduan.put("name", guanduanList.get(j)==null?"":guanduanList.get(j).toString());
				guanduan.put("isParent", false);
				jsonArray.add(guanduan);
				
			}
			//阀门根节点
			JSONObject valveRoot = GenerateNode("valveRoot"+pipeLineNO,"gx"+pipeLineNO,"阀门",true);
			jsonArray.add(valveRoot);
			JSONArray jsonArray1=getValveNode("valveRoot"+pipeLineNO);	
			for(int j=0;j<jsonArray1.size();j++){
				jsonArray.add(jsonArray1.get(j));
			}
		}
		System.out.print(jsonArray.toString());
		out.print(jsonArray.toString());
	}
	
	public void getGuanxianTreeByAutosearchPipeSection() throws IOException{
		List<String> guanduanlists = getListByAutosearch();		
		PrintWriter out=PubMethod.GetPrintWriter();
		JSONArray jsonArray = new JSONArray();	
		JSONObject guanwangroot = new JSONObject();
		guanwangroot.put("id", "root");
		guanwangroot.put("pId", "-1");
		//guanwangroot.put("name", "北京管网");
		guanwangroot.put("name", "管段查询结果");
		guanwangroot.put("isParent", true);
		guanwangroot.put("open", true);
		jsonArray.add(guanwangroot);
		JSONObject guanxianroot = new JSONObject();
		//guanxianroot.put("id", "guanxianroot");
		guanxianroot.put("id", "guanxianrootR");
		guanxianroot.put("pId", "root");
		guanxianroot.put("name", "管线");
		guanwangroot.put("isParent", true);
		jsonArray.add(guanxianroot);
		String strSql;
		List<String> guanxianlists=new ArrayList();
		for(int i=0;i<guanduanlists.size();i++)
		{
			String pipelineno=guanduanlists.get(i).substring(0,9);
			if(guanxianlists.contains(pipelineno)==false)
			{
				guanxianlists.add(pipelineno);
			}
		}
		for(int i=0;i<guanxianlists.size();i++){
			String pipelineno=guanxianlists.get(i).toString();
			JSONObject guanxian = new JSONObject();
			guanxian.put("id", "gx"+guanxianlists.get(i).toString());
			//guanxian.put("pId", "guanxianroot");
			guanxian.put("pId", "guanxianrootR");
			guanxian.put("name", guanxianlists.get(i).toString());
			jsonArray.add(guanxian);
			
			JSONObject guanduanroot = new JSONObject();
			guanduanroot.put("id", "gdroot"+guanxianlists.get(i).toString());
			guanduanroot.put("pId", "gx"+guanxianlists.get(i).toString());
			guanduanroot.put("name", "管段");
			guanduanroot.put("isParent", true);
			jsonArray.add(guanduanroot);	
			for(int j=0;j<guanduanlists.size();j++){
				String pipesectionno=guanduanlists.get(j);
				if(pipesectionno.substring(0,9).equals(pipelineno))
				{
					JSONObject guanduan = new JSONObject();
					guanduan.put("id", "gd"+guanduanlists.get(j)==null?"":guanduanlists.get(j).toString());
					guanduan.put("pId", "gdroot"+guanxianlists.get(i).toString());
					guanduan.put("name", guanduanlists.get(j)==null?"":guanduanlists.get(j).toString());
					guanduan.put("isParent", false);
					jsonArray.add(guanduan);
				}	
			}
			//阀门根节点
			JSONObject valveRoot = GenerateNode("valveRoot"+pipelineno,"gx"+pipelineno,"阀门",true);
			jsonArray.add(valveRoot);
			JSONArray jsonArray1=getValveNode("valveRoot"+pipelineno);	
			for(int j=0;j<jsonArray1.size();j++){
				jsonArray.add(jsonArray1.get(j));
			}
		}
		System.out.print(jsonArray.toString());
		out.print(jsonArray.toString());
	}
	
	public void getGuanxianTreeByAutosearchTask() throws IOException{
		List<String> tasklists = getListByAutosearch();	
		//List<String> guanxianlists = getListByAutosearch();		
		PrintWriter out=PubMethod.GetPrintWriter();
		JSONArray jsonArray = new JSONArray();	
		JSONObject guanwangroot = new JSONObject();
		guanwangroot.put("id", "root");
		guanwangroot.put("pId", "-1");
		//guanwangroot.put("name", "北京管网");
		guanwangroot.put("name", "任务查询结果");
		guanwangroot.put("isParent", true);
		guanwangroot.put("open", true);
		jsonArray.add(guanwangroot);
		JSONObject taskroot = new JSONObject();
		taskroot.put("id", "taskroot");
		taskroot.put("pId", "root");
		taskroot.put("name", "任务");
		taskroot.put("isParent", true);
		jsonArray.add(taskroot);
		String strSql;
		//查询到的任务及任务下的管线、管段，管线下的管段
		for(int i=0;i<tasklists.size();i++){
			String taskno=tasklists.get(i).toString();		
			JSONObject task = new JSONObject();
			task.put("id", "task"+taskno);
			task.put("pId", "taskroot");
			task.put("name", taskno);
			jsonArray.add(task);
			JSONObject guanxianroot = new JSONObject();
			//guanxianroot.put("id", "gx"+taskno);
			guanxianroot.put("id", "rootgx"+taskno);
			guanxianroot.put("pId", "task"+taskno);
			guanxianroot.put("name", "管线");
			guanxianroot.put("isParent", true);
			jsonArray.add(guanxianroot);
			//任务下的管线
			List<String> guanxianlists=getTaskPipeLines(taskno);
			int num=guanxianlists.size();
			for(int j=0;j<num;j++)
			{
				JSONObject guanxian = new JSONObject();
				String pipelineno=guanxianlists.get(j).toString();	
				guanxian.put("id", "gx"+pipelineno);
				//guanxian.put("pId", "gx"+taskno);
				guanxian.put("pId", "rootgx"+taskno);
				guanxian.put("name", pipelineno);
				guanxian.put("isParent", true);
				jsonArray.add(guanxian);
				//管线下的管段
				JSONObject guanduanroot = new JSONObject();
				guanduanroot.put("id", "gdroot"+pipelineno);
				guanduanroot.put("pId", "gx"+pipelineno);
				guanduanroot.put("name", "管段");
				guanduanroot.put("isParent", true);
				jsonArray.add(guanduanroot);
				strSql = "select t.pipesectionno from ptem_pipesection t where " +
				"t.PIPELINENO='"+pipelineno+"' " ;
				List guanduanList = dbService.queryDataBySql(strSql);
				for(int k=0;k<guanduanList.size();k++){
					JSONObject guanduan = new JSONObject();
					String pipeSectionno=guanduanList.get(k).toString();
					guanduan.put("id", "gd"+pipeSectionno);
					guanduan.put("pId", "gdroot"+pipelineno);
					guanduan.put("name", pipeSectionno);
					guanduan.put("isParent", false);
					jsonArray.add(guanduan);
				}
				
				//阀门根节点
				JSONObject valveRoot = GenerateNode("valveRoot"+pipelineno,"gx"+pipelineno,"阀门",true);
				jsonArray.add(valveRoot);
				JSONArray jsonArray1=getValveNode("valveRoot"+pipelineno);	
				for(int p=0;p<jsonArray1.size();p++){
					jsonArray.add(jsonArray1.get(p));
				}
			}
			
			//任务下的管段
			JSONObject guanduanroot = new JSONObject();
			guanduanroot.put("id", "gdroot"+taskno);
			guanduanroot.put("pId", "task"+taskno);
			guanduanroot.put("name", "管段");
			guanduanroot.put("isParent", true);
			jsonArray.add(guanduanroot);
			List<String> guanduanlists=getTaskPipeSections(taskno);
			if(guanduanlists!=null)
			{
				num=guanduanlists.size();				
				for(int index=0;index<num;index++)
				{
					JSONObject guanduan = new JSONObject();
					String pipeSectionno=guanduanlists.get(index).toString();
					guanduan.put("id", "gd"+pipeSectionno);
					guanduan.put("pId", "gdroot"+taskno);
					guanduan.put("name", pipeSectionno);
					guanduan.put("isParent", false);
					jsonArray.add(guanduan);
				}
			}	
			JSONObject zhanxiangroot = new JSONObject();
			//guanxianroot.put("id", "gx"+taskno);
			zhanxiangroot.put("id", "rootzhx"+taskno);
			zhanxiangroot.put("pId", "task"+taskno);
			zhanxiangroot.put("name", "站箱");
			zhanxiangroot.put("isParent", true);
			jsonArray.add(zhanxiangroot);
			//任务下的站箱
			List<String> zhanxianglists=getTaskStations(taskno);
			num=zhanxianglists.size();
			for(int j=0;j<num;j++)
			{
				JSONObject guanxian = new JSONObject();
				String zhanxiangname=zhanxianglists.get(j).toString();	
				guanxian.put("id", "zx"+zhanxiangname);
				//guanxian.put("pId", "gx"+taskno);
				guanxian.put("pId", "rootzhx"+taskno);
				guanxian.put("name", zhanxiangname);
				guanxian.put("isParent", false);
				jsonArray.add(guanxian);
			}
		}
		System.out.print(jsonArray.toString());
		out.print(jsonArray.toString());
	}
	public List<String> getGuanxianlist(List<List<Object[]>> lists) throws IOException{
		List<String> guanxianlist=new ArrayList(); //管线列表
		int typenum=lists.size();
		for(int i=0;i<typenum;i++)
		{
			List<Object[]> list=lists.get(i);
			int num=list.size();
			for(int j=0;j<num;j++)
			{
				Object[] obj=list.get(j);
				if(obj[0]!=null)
				{
					String pipelineno=obj[0].toString();
					if(!guanxianlist.contains(pipelineno))
					{
						guanxianlist.add(pipelineno);
					}					
				}
			}
		}
		return guanxianlist;
	}
	public List<String> getGuanduanlist(List<List<Object[]>> lists) throws IOException{
		List<String> guanduanlist=new ArrayList(); //管段列表
		int typenum=lists.size();
		for(int i=0;i<typenum;i++)
		{
			List<Object[]> list=lists.get(i);
			int num=list.size();
			for(int j=0;j<num;j++)
			{
				Object[] obj=list.get(j);
				if(obj[1]!=null)
				{
					String pipesectionno=obj[1].toString();
					if(!guanduanlist.contains(pipesectionno))
					{
						guanduanlist.add(pipesectionno);
					}
				}
			}
		}
		return guanduanlist;
	}

	public List<String> getGuanxianlist(Map<String, List<Object[]> > map) throws IOException{
		List<String> guanxianlist=new ArrayList(); //管线列表
		
		for(Map.Entry<String, List<Object[]> > entry : map.entrySet()){  
			    List<Object[]> list=(List<Object[]>) entry.getValue();  
			    int num=list.size();
				for(int j=0;j<num;j++)
				{
					Object[] obj=list.get(j);
					if(obj[0]!=null)
					{
						String pipelineno=obj[0].toString();
						if(!guanxianlist.contains(pipelineno))
						{
							guanxianlist.add(pipelineno);
						}					
					}
				}
		}  
		return guanxianlist;
	}
	public List<String> getGuanduanlist(Map<String, List<Object[]> > map) throws IOException{
		List<String> guanduanlist=new ArrayList(); //管段列表
		
		for(Map.Entry<String, List<Object[]> > entry : map.entrySet())
		{
			 List<Object[]> list=(List<Object[]>) entry.getValue();  
			int num=list.size();
			for(int j=0;j<num;j++)
			{
				Object[] obj=list.get(j);
				if(obj[1]!=null)
				{
					String pipesectionno=obj[1].toString();
					if(!guanduanlist.contains(pipesectionno))
					{
						guanduanlist.add(pipesectionno);
					}
				}
			}
		}
		return guanduanlist;
	}

	
	public List<JSONObject> generatePipePointNode(String type,List<Object[]> list,String pipelineno) throws IOException{
		String typeroot="";
		if(type.equals("tz"))
		{
			typeroot=type+"root";
		}
		else
		{
			typeroot=type+"Root";
		}
		List<JSONObject> listobj=new ArrayList();
		int num=list.size();
		for(int j=0;j<num;j++)
		{
			String guanxianno="";
			String pointno="";
			Object[] obj=list.get(j);
			if(obj[0]!=null)
			{
				guanxianno=obj[0].toString();									
			}
			if(obj[1]!=null)
			{
				pointno=obj[1].toString();
			}
			if(guanxianno.equals(pipelineno)&&pointno!="")
			{
				JSONObject tezhengd = GenerateNode(type+pointno,typeroot+pipelineno,pointno,false);
				listobj.add(tezhengd);
			}
		}
		return listobj;
	}
	public void getGuanxianTreeByAutosearchPipePoint() throws IOException{		
		PrintWriter out=PubMethod.GetPrintWriter();
		JSONArray jsonArray = new JSONArray();	
		JSONObject guanwangroot = new JSONObject();
		guanwangroot.put("id", "root");
		guanwangroot.put("pId", "-1");
		//guanwangroot.put("name", "北京管网");
		guanwangroot.put("name", "特征点查询结果");
		guanwangroot.put("isParent", true);
		guanwangroot.put("open", true);
		jsonArray.add(guanwangroot);
		JSONObject guanxianroot = new JSONObject();
		//guanxianroot.put("id", "guanxianroot");
		guanxianroot.put("id", "guanxianrootR");
		guanxianroot.put("pId", "root");
		guanxianroot.put("name", "管线");
		guanwangroot.put("isParent", true);
		jsonArray.add(guanxianroot);
		//查询特征点、三通、阳极等
		Map map = getListByAutosearchPipePoint();	
//		int types=lists.size();
//		if(types!=20)
//		{
//			return;
//		}
		//获取查询到的所有管线和所有管段
		List<String> guanxianlist=getGuanxianlist(map); //管线列表
		//List<String> guanduanlist=getGuanduanlist(map); //管段列表
		//生成节点
		int guanxiannum=guanxianlist.size();
		//int guanduannum=guanduanlist.size();
		for(int i=0;i<guanxiannum;i++){
			String pipelineno=guanxianlist.get(i).toString();
			//JSONObject guanxian = GenerateNode("gx"+pipelineno,"guanxianroot",pipelineno,true);
			JSONObject guanxian = GenerateNode("gx"+pipelineno,"guanxianrootR",pipelineno,true);	
			jsonArray.add(guanxian);	
			//管线下的管段
			JSONObject guanduanroot = new JSONObject();
			guanduanroot.put("id", "gdroot"+pipelineno);
			guanduanroot.put("pId", "gx"+pipelineno);
			guanduanroot.put("name", "管段");
			guanduanroot.put("isParent", true);
			jsonArray.add(guanduanroot);
			String strSql = "select t.pipesectionno from ptem_pipesection t where " +
			"t.PIPELINENO='"+pipelineno+"' " ;
			List guanduanList = dbService.queryDataBySql(strSql);
			for(int k=0;k<guanduanList.size();k++){
				JSONObject guanduan = new JSONObject();
				String pipeSectionno=guanduanList.get(k).toString();
				guanduan.put("id", "gd"+pipeSectionno);
				guanduan.put("pId", "gdroot"+pipelineno);
				guanduan.put("name", pipeSectionno);
				guanduan.put("isParent", false);
				jsonArray.add(guanduan);
			}
			//阀门根节点
			JSONObject valveRoot = GenerateNode("valveRoot"+pipelineno,"gx"+pipelineno,"阀门",true);
			jsonArray.add(valveRoot);
			JSONArray jsonArray1=getValveNode("valveRoot"+pipelineno);	
			for(int j=0;j<jsonArray1.size();j++){
				jsonArray.add(jsonArray1.get(j));
			}
			List<JSONObject> objlist=new ArrayList();
			List<Object[]> list=new ArrayList();
			//特征点		
			JSONObject tezhengdroot = GenerateNode("tzroot"+pipelineno,"gx"+pipelineno,"特征点",true);
			jsonArray.add(tezhengdroot);
			list=(List<Object[]>) map.get("特征点");
			if(list!=null)
			{
				objlist=generatePipePointNode("tz",list,pipelineno);
				for(int k=0;k<objlist.size();k++)
				{
					jsonArray.add(objlist.get(k));		
				}
			}
			
			//管件				
			JSONObject root = GenerateNode("gjroot"+pipelineno,"gx"+pipelineno,"管件",true);
			jsonArray.add(root);
			//三通
			JSONObject santongdroot = GenerateNode("pointTeeRoot"+pipelineno,"gjroot"+pipelineno,"三通",true);
			jsonArray.add(santongdroot);
			list=(List<Object[]>) map.get("三通");
			if(list!=null)
			{
				objlist=generatePipePointNode("pointTee",list,pipelineno);
				for(int k=0;k<objlist.size();k++)
				{
					jsonArray.add(objlist.get(k));		
				}
			}
			
			//套管
			JSONObject taoguanroot = GenerateNode("taoguanRoot"+pipelineno,"gjroot"+pipelineno,"套管",true);
			jsonArray.add(taoguanroot);
			list=(List<Object[]>) map.get("套管");
			if(list!=null)
			{
				objlist=generatePipePointNode("taoguan",list,pipelineno);
				for(int k=0;k<objlist.size();k++)
				{
					jsonArray.add(objlist.get(k));		
				}
			}
			
			//弯管
			JSONObject wanguanroot = GenerateNode("wanguanRoot"+pipelineno,"gjroot"+pipelineno,"弯管",true);
			jsonArray.add(wanguanroot);	
			list=(List<Object[]>) map.get("弯管");
			if(list!=null)
			{
				objlist=generatePipePointNode("wanguan",list,pipelineno);
				for(int k=0;k<objlist.size();k++)
				{
					jsonArray.add(objlist.get(k));		
				}
			}
			
			//穿跨越				
			root = GenerateNode("chuankuayRoot"+pipelineno,"gx"+pipelineno,"穿跨越",true);
			jsonArray.add(root);
			list=(List<Object[]>) map.get("穿跨越");
			if(list!=null)
			{
				objlist=generatePipePointNode("chuankuay",list,pipelineno);
				for(int k=0;k<objlist.size();k++)
				{
					jsonArray.add(objlist.get(k));		
				}
			}
			
			//内衬					
			root = GenerateNode("neichenRoot"+pipelineno,"gx"+pipelineno,"内衬",true);
			jsonArray.add(root);
			list=(List<Object[]>) map.get("内衬");
			if(list!=null)
			{
				objlist=generatePipePointNode("neichen",list,pipelineno);
				for(int k=0;k<objlist.size();k++)
				{
					jsonArray.add(objlist.get(k));		
				}
			}
			
			//附属设施
			root = GenerateNode("fsssroot"+pipelineno,"gx"+pipelineno,"附属设施",true);
			jsonArray.add(root);
		
			//阳极
			JSONObject yangjiroot = GenerateNode("pointAnodeRoot"+pipelineno,"fsssroot"+pipelineno,"阳极",true);
			jsonArray.add(yangjiroot);
			list=(List<Object[]>) map.get("阳极");
			if(list!=null)
			{
				objlist=generatePipePointNode("pointAnode",list,pipelineno);
				for(int k=0;k<objlist.size();k++)
				{
					jsonArray.add(objlist.get(k));		
				}
			}
			
			//测试桩
			JSONObject ceshizhuangroot = GenerateNode("pointPoleRoot"+pipelineno,"fsssroot"+pipelineno,"测试桩",true);
			jsonArray.add(ceshizhuangroot);
			list=(List<Object[]>) map.get("测试桩");
			if(list!=null)
			{
				objlist=generatePipePointNode("pointPole",list,pipelineno);
				for(int k=0;k<objlist.size();k++)
				{
					jsonArray.add(objlist.get(k));		
				}
			}
			
			//排流装置
			JSONObject pailiuzhuangzhiroot = GenerateNode("pointDrainageRoot"+pipelineno,"fsssroot"+pipelineno,"排流装置",true);
			jsonArray.add(pailiuzhuangzhiroot);
			list=(List<Object[]>) map.get("排流装置");
			if(list!=null)
			{
				objlist=generatePipePointNode("pointDrainage",list,pipelineno);
				for(int k=0;k<objlist.size();k++)
				{
					jsonArray.add(objlist.get(k));		
				}
			}
			
			//阀门
//			root = GenerateNode("famenRoot"+pipelineno,"gx"+pipelineno,"阀门",true);
//			jsonArray.add(root);
//			list=(List<Object[]>) map.get("阀门");
//			if(list!=null)
//			{
//				objlist=generatePipePointNode("famen",list,pipelineno);
//				for(int k=0;k<objlist.size();k++)
//				{
//					jsonArray.add(objlist.get(k));		
//				}
//			}
			
			//站箱
			root = GenerateNode("zhanxiangRoot"+pipelineno,"gx"+pipelineno,"站箱",true);
			jsonArray.add(root);
			list=(List<Object[]>) map.get("站箱");
			if(list!=null)
			{
				objlist=generatePipePointNode("zhanxiang",list,pipelineno);
				for(int k=0;k<objlist.size();k++)
				{
					jsonArray.add(objlist.get(k));		
				}	
			}
			
			//过滤器
			JSONObject child1 = GenerateNode("guolvqiRoot"+pipelineno,"zhanxiangRoot"+pipelineno,"过滤器",true);
			jsonArray.add(child1);
			list=(List<Object[]>) map.get("过滤器");
			if(list!=null)
			{
				objlist=generatePipePointNode("guolvqi",list,pipelineno);
				for(int k=0;k<objlist.size();k++)
				{
					jsonArray.add(objlist.get(k));		
				}
			}
		
			//安全阀
			JSONObject child2 = GenerateNode("anquanfaRoot"+pipelineno,"zhanxiangRoot"+pipelineno,"安全阀",true);
			jsonArray.add(child2);
			list=(List<Object[]>) map.get("安全阀");
			if(list!=null)
			{
				objlist=generatePipePointNode("anquanfa",list,pipelineno);
				for(int k=0;k<objlist.size();k++)
				{
					jsonArray.add(objlist.get(k));		
				}
			}
			
			//生产运行
			root = GenerateNode("shchyxRoot"+pipelineno,"gx"+pipelineno,"生产运行",true);
			jsonArray.add(root);
			//异常
			JSONObject yichangroot = GenerateNode("yichangRoot"+pipelineno,"shchyxRoot"+pipelineno,"异常",true);
			jsonArray.add(yichangroot);
			list=(List<Object[]>) map.get("异常");
			if(list!=null)
			{
				objlist=generatePipePointNode("yichang",list,pipelineno);
				for(int k=0;k<objlist.size();k++)
				{
					jsonArray.add(objlist.get(k));		
				}
			}
			
			//特殊段
			JSONObject teshuduanroot = GenerateNode("teshuduanRoot"+pipelineno,"shchyxRoot"+pipelineno,"特殊段",true);
			jsonArray.add(teshuduanroot);
			list=(List<Object[]>) map.get("特殊段");
			if(list!=null)
			{
				objlist=generatePipePointNode("teshuduan",list,pipelineno);
				for(int k=0;k<objlist.size();k++)
				{
					jsonArray.add(objlist.get(k));		
				}
			}
			
			//违章占压
			JSONObject wzzyroot = GenerateNode("wzzyRoot"+pipelineno,"shchyxRoot"+pipelineno,"违章占压",true);
			jsonArray.add(wzzyroot);	
			list=(List<Object[]>) map.get("违章占压");
			if(list!=null)
			{
				objlist=generatePipePointNode("wzzy",list,pipelineno);
				for(int k=0;k<objlist.size();k++)
				{
					jsonArray.add(objlist.get(k));		
				}
			}
			
			//应急事件
			root = GenerateNode("shijianRoot"+pipelineno,"gx"+pipelineno,"事件",true);
			jsonArray.add(root);
			child1 = GenerateNode("sjdRoot"+pipelineno,"shijianRoot"+pipelineno,"应急事件",true);
			jsonArray.add(child1);	
			list=(List<Object[]>) map.get("应急事件");	
			if(list!=null)
			{
				objlist=generatePipePointNode("sjd",list,pipelineno);
				for(int k=0;k<objlist.size();k++)
				{
					jsonArray.add(objlist.get(k));		
				}
			}		
			//泄漏点
			root = GenerateNode("xldRoot"+pipelineno,"shijianRoot"+pipelineno,"泄漏点",true);
			jsonArray.add(root);	
			list=(List<Object[]>) map.get("泄漏点");
			if(list!=null)
			{
				objlist=generatePipePointNode("xieloudian",list,pipelineno);
				for(int k=0;k<objlist.size();k++)
				{
					jsonArray.add(objlist.get(k));		
				}
			}			
			//生产作业				
			root = GenerateNode("shchzyRoot"+pipelineno,"gx"+pipelineno,"生产作业",true);
			jsonArray.add(root);

			//生产作业点
			child1 = GenerateNode("shengchanzydRoot"+pipelineno,"shchzyRoot"+pipelineno,"生产作业",true);
			jsonArray.add(child1);
	
			list=(List<Object[]>) map.get("生产作业");
			if(list!=null)
			{
				objlist=generatePipePointNode("shengchanzyd",list,pipelineno);
				for(int k=0;k<objlist.size();k++)
				{
					jsonArray.add(objlist.get(k));		
				}
			}
			
			//带气作业机械预制件
			child2 = GenerateNode("dqzyjxyzhRoot"+pipelineno,"shchzyRoot"+pipelineno,"带气作业机械预制件",true);
			jsonArray.add(child2);
			list=(List<Object[]>) map.get("带气作业机械预制件");
			if(list!=null)
			{
				objlist=generatePipePointNode("dqzyjxyzh",list,pipelineno);
				for(int k=0;k<objlist.size();k++)
				{
					jsonArray.add(objlist.get(k));		
				}
			}			
		}
		System.out.print(jsonArray.toString());
		out.print(jsonArray.toString());
	}
	
	public void getGuanxianTreeByguanduansearch() throws IOException{
		List<String> guanxianlists = getGuanxianList();		
		PrintWriter out=PubMethod.GetPrintWriter();
		JSONArray jsonArray = new JSONArray();	
		JSONObject guanwangroot = new JSONObject();
		guanwangroot.put("id", "root");
		guanwangroot.put("pId", "-1");
		guanwangroot.put("name", "北京管网");
		guanwangroot.put("isParent", true);
		guanwangroot.put("open", true);
		jsonArray.add(guanwangroot);
		JSONObject guanxianroot = new JSONObject();
		guanxianroot.put("id", "guanxianroot");
		guanxianroot.put("pId", "root");
		guanxianroot.put("name", "管线");
		guanwangroot.put("isParent", true);
		jsonArray.add(guanxianroot);
		String strSql;
		for(int i=0;i<guanxianlists.size();i++){
			JSONObject guanxian = new JSONObject();
			guanxian.put("id", "gx"+guanxianlists.get(i).toString());
			guanxian.put("pId", "guanxianroot");
			guanxian.put("name", guanxianlists.get(i).toString());
			jsonArray.add(guanxian);
			
			JSONObject guanduanroot = new JSONObject();
			guanduanroot.put("id", "gdroot"+guanxianlists.get(i).toString());
			guanduanroot.put("pId", "gx"+guanxianlists.get(i).toString());
			guanduanroot.put("name", "管段");
			guanduanroot.put("isParent", true);
			jsonArray.add(guanduanroot);
			
			strSql = "select t.pipesectionno from ptem_pipesection t where " +
					"t.PIPELINENO='"+guanxianlists.get(i).toString()+"' " ;
			List guanduanList = dbService.queryDataBySql(strSql);
			for(int j=0;j<guanduanList.size();j++){
				JSONObject guanduan = new JSONObject();
				guanduan.put("id", "gd"+guanduanList.get(j)==null?"":guanduanList.get(j).toString());
				guanduan.put("pId", "gdroot"+guanxianlists.get(i).toString());
				guanduan.put("name", guanduanList.get(j)==null?"":guanduanList.get(j).toString());
				guanduan.put("isParent", false);
				jsonArray.add(guanduan);
			}
		}
		System.out.print(jsonArray.toString());
		out.print(jsonArray.toString());
	}
	

	//查询三通列表
	public void queryPointTeeList(){
		try{
			String tzid = getRequest().getParameter("tzid");
			//去掉root
			tzid=tzid.substring(4);
			Map<String,String> filterMap=getPagerMap();
			if(null!=tzid && !"".equals(tzid)){
				filterMap.put("tzid", tzid);
			}
			PageResult result= guanxianService.queryPointTeeList(filterMap);
			String[] viewArray={"ID","TEENO","LOCATIONY",
					"LOCATIONX","HEIGHT","LONGITUDE","LATITUDE","ELLIPSEH",
					"TYPE","MAINTHICKNESS","MAINDIAMETER","BRANCHTHICKNESS","BRANCHDIAMETER",
					"PRESSURELEVEL","REMARK","PIPELINENO","PIPESECTIONNO","ATTACHMENT",
					"SIGNEDUNIT","SIGNED"};
			String str=getColumnJson(result,viewArray);
			HttpServletResponse response = ServletActionContext.getResponse();
			response.setContentType("application/XML,charset=GBK");
			response.setHeader("Charset", "GBK");
			response.setCharacterEncoding("GBK");
			response.setContentType("text/xml");
			PrintWriter out = getResponse().getWriter();
			out.print(str);
			}
			catch (Exception e) {
				e.printStackTrace();
			}
	}
	
	public void queryTezhengdlist(){
		try{
			String tzid = getRequest().getParameter("tzid");
			//去掉root
			tzid=tzid.substring(4);
			Map<String,String> filterMap=getPagerMap();
			if(null!=tzid && !"".equals(tzid)){
				filterMap.put("tzid", tzid);
			}
			PageResult result= guanxianService.queryTezhengdlist(filterMap);
			String[] viewArray={"ID","POINTNO","POINTNAME","GROUNDMARK","LOCATIONY","LOCATIONX",
					"HEIGHT","LONGITUDE","LATITUDE","ELLIPSOIDH","REMARK","PIPELINENO",
					"PIPESECTIONNO","SIGNEDUNIT","SIGNED"};
			String str=getColumnJson(result,viewArray);
			HttpServletResponse response = ServletActionContext.getResponse();
			response.setContentType("application/XML,charset=GBK");
			response.setHeader("Charset", "GBK");
			response.setCharacterEncoding("GBK");
			response.setContentType("text/xml");
			PrintWriter out = getResponse().getWriter();
			out.print(str);
			}
			catch (Exception e) {
				e.printStackTrace();
			}
	}
	
//	public void getGuanduanlistbyguanxianid(){
//		try{
//			String treeid = getRequest().getParameter("treeid");
//			String strWhere = "";
//			if (treeid.indexOf("gx")>=0||treeid.indexOf("gxroot")>=0){
//				String gxid = treeid.replace("gxroot", "").replace("gx", "");
//				strWhere += "and t.pipelineno='"+gxid+"' ";
//			}
//			if (treeid.indexOf("gdroot")>=0){
//				String gdid = treeid.replace("gdroot", "");
//				strWhere += "and t.pipelineno='"+gdid+"' ";
//			}
//			else if (treeid.indexOf("gd")>=0){
//				String gdid = treeid.replace("gd", "");
//				strWhere += "and t.pipesectionno='"+gdid+"' ";
//			}
//			
//			String colorSql = "";
//			String leftSql = "";
//			colorSql += ",t2.RISKASSESSMENTLEVEL27512  as colorlevel1 ";
//			leftSql += " left join PTEM_SECURITY_ASSESS t2 on t2.PIPENETNO=t.pipesectionno  ";
//			colorSql += ",t3.RISKASSESSMENTLEVELWAY2  as colorlevel2 ";
//			leftSql += " left join PTEM_SECURITY_ASSESS t3 on t3.PIPENETNO=t.pipesectionno  ";
////			String strSql = "select t.beginnodel,t.beginnodeb,t.endnodel,t.endnodeb,t.pipesectionno " + colorSql+ 
////			" from ptem_pipesection t "+leftSql+" where 1=1 "+strWhere;
//			String strSql = "select t.beginnodel_map,t.beginnodeb_map,t.endnodel_map,t.endnodeb_map,t.pipesectionno " + colorSql+ 
//					" from ptem_pipesection t "+leftSql+" where 1=1 "+strWhere;
//			List lists = dbService.queryDataBySql(strSql);
//			JSONArray jsonArray = new JSONArray();
//			for(int i=0;i<lists.size();i++){
//				Object[] objs = (Object[])lists.get(i);
//				JSONObject jsonobj = new JSONObject();
//				jsonobj.put("beginnodel", objs[0]==null?"":objs[0].toString());
//				jsonobj.put("beginnodeb", objs[1]==null?"":objs[1].toString());
//				jsonobj.put("endnodel", objs[2]==null?"":objs[2].toString());
//				jsonobj.put("endnodeb", objs[3]==null?"":objs[3].toString());
//				jsonobj.put("pipesectionno", objs[4]==null?"":objs[4].toString());
//				jsonobj.put("colorlevel1", objs[5]==null?"":objs[5].toString());
//				jsonobj.put("colorlevel2", objs[6]==null?"":objs[6].toString());
//				jsonArray.add(jsonobj);
//			}
//			PrintWriter out = getResponse().getWriter();
//			out.print(jsonArray.toString());
//		}
//		catch (Exception e) {
//			e.printStackTrace();
//		}
//	}
	
	//获取表9-1安全状况评估方法二风险评估等级
	public String  getColorlevelSecurityWAY2(String pipelineno,String pipesectionno){
		String sql="select t.RISKASSESSMENTLEVELWAY2 from PTEM_COATING_RISO_EVALUATE t " +
		"where t.PIPENO='"+pipesectionno+"'";
		sql+=" order by (cast(t.id as int)) desc";
		List<Object> list=dbService.queryDataBySql(sql);
		String colorlevelRiso="";
		if(list.size()==0)
		{
			sql="select t.RISKASSESSMENTLEVELWAY2 from PTEM_COATING_RISO_EVALUATE t " +
			"where t.PIPELINENO='"+pipelineno+"'";
			sql+=" order by (cast(t.id as int)) desc";
			List<Object> listT=dbService.queryDataBySql(sql);
			if(listT.size()!=0)
			{
				Object obj=listT.get(0);
				if(obj!=null)
				{
					colorlevelRiso=obj.toString();
				}				
			}
		}
		else
		{
			Object obj=list.get(0);
			if(obj!=null)
			{
				colorlevelRiso=obj.toString();
			}	
		}
		return colorlevelRiso;
	}
	//获取表9-1安全状况评估27512风险评估等级
	public String  getColorlevelSecurity(String table,String field,String pipelineno,String pipesectionno){
		String sql="select t."+field+" from "+table+" t " +
		"where t.PIPENETNO like '%"+pipesectionno+"%'";
		sql+=" order by (cast(t.id as int)) desc";
		List<Object> list=dbService.queryDataBySql(sql);
		String colorlevel="";
		if(list.size()==0)
		{
			sql="select t."+field+" from "+table+" t " +
			"where t.PIPELINENO='"+pipelineno+"'";
			sql+=" order by (cast(t.id as int)) desc";
			List<Object> listT=dbService.queryDataBySql(sql);
			if(listT.size()!=0)
			{
				Object obj=listT.get(0);
				if(obj!=null)
				{
					colorlevel=obj.toString();
				}				
			}
		}
		else
		{
			Object obj=list.get(0);
			if(obj!=null)
			{
				colorlevel=obj.toString();
			}	
		}
		return colorlevel;
	}
	//获取表5-7绝缘电阻值评定等级
	public String  getColorlevelRiso(String pipelineno,String pipesectionno){
		String sql="select t.RISOVALUELEVEL from PTEM_COATING_RISO_EVALUATE t " +
		"where t.PIPENO='"+pipesectionno+"'";
		sql+=" order by (cast(t.id as int)) desc";
		List<Object> list=dbService.queryDataBySql(sql);
		String colorlevelRiso="";
		if(list.size()==0)
		{
			sql="select t.RISOVALUELEVEL from PTEM_COATING_RISO_EVALUATE t " +
			"where t.PIPELINENO='"+pipelineno+"'";
			sql+=" order by (cast(t.id as int)) desc";
			List<Object> listT=dbService.queryDataBySql(sql);
			if(listT.size()!=0)
			{
				Object obj=listT.get(0);
				if(obj!=null)
				{
					colorlevelRiso=obj.toString();
				}				
			}
		}
		else
		{
			Object obj=list.get(0);
			if(obj!=null)
			{
				colorlevelRiso=obj.toString();
			}	
		}
		return colorlevelRiso;
	}
	//获取表5-10管地电位范围 
	public String  getColorlevelPotential(String pipelineno,String pipesectionno){
		String sql="select t.POTENTIALRANGE from PTEM_CP_EVALUATE t " +
		"where t.PIPENO='"+pipesectionno+"'";
		sql+=" order by (cast(t.id as int)) desc";
		List<Object> list=dbService.queryDataBySql(sql);
		String colorlevel="";
		if(list.size()==0)
		{
			sql="select t.POTENTIALRANGE from PTEM_CP_EVALUATE t " +
			"where t.PIPELINENO='"+pipelineno+"'";
			sql+=" order by (cast(t.id as int)) desc";
			List<Object> listT=dbService.queryDataBySql(sql);
			if(listT.size()!=0)
			{
				Object obj=listT.get(0);
				if(obj!=null)
				{
					colorlevel=obj.toString();
				}				
			}
		}
		else
		{
			Object obj=list.get(0);
			if(obj!=null)
			{
				colorlevel=obj.toString();
			}	
		}
		if(colorlevel.equals("850~1200"))
		{
			colorlevel="2";
		}
		else if(colorlevel.equals(">1200"))
		{
			colorlevel="3";
		}
		else if(colorlevel.equals(">1200"))
		{
			colorlevel="4";
		}
		return colorlevel;
	}
	public void getGuanduanlistbyguanxianid(){
		try{
			String treeid = getRequest().getParameter("treeid");
			String strWhere = "";			
			if (treeid.indexOf("gx")>=0||treeid.indexOf("gxroot")>=0){
				String gxid = treeid.replace("gxroot", "").replace("gx", "");
				strWhere += "and t.pipelineno='"+gxid+"' ";
			}
			if (treeid.indexOf("gdroot")>=0){
				String gdid = treeid.replace("gdroot", "");
				strWhere += "and t.pipelineno='"+gdid+"' ";
			}
			else if (treeid.indexOf("gd")>=0){
				String gdid = treeid.replace("gd", "");
				strWhere += "and t.pipesectionno='"+gdid+"' ";
			}
			
			String colorSql = "";
			String leftSql = "";
			colorSql += ",t2.RISKASSESSMENTLEVEL27512  as colorlevel1 ";
			leftSql += " left join PTEM_SECURITY_ASSESS t2 on t2.PIPENETNO=t.pipesectionno  ";
			colorSql += ",t3.RISKASSESSMENTLEVELWAY2  as colorlevel2 ";
			leftSql += " left join PTEM_SECURITY_ASSESS t3 on t3.PIPENETNO=t.pipesectionno  ";
//			String strSql = "select t.beginnodel,t.beginnodeb,t.endnodel,t.endnodeb,t.pipesectionno " + colorSql+ 
//			" from ptem_pipesection t "+leftSql+" where 1=1 "+strWhere;
			String strSql = "select t.beginnodel_map,t.beginnodeb_map,t.endnodel_map,t.endnodeb_map,t.pipesectionno " + colorSql+ 
					" from ptem_pipesection t "+leftSql+" where 1=1 "+strWhere;
			List lists = dbService.queryDataBySql(strSql);
			JSONArray jsonArray = new JSONArray();
			
			for(int i=0;i<lists.size();i++){
				Object[] objs = (Object[])lists.get(i);
				String pipesectionno=objs[4].toString();
				String pipelineno=pipesectionno.substring(0,9);
				JSONObject jsonobj = new JSONObject();
				jsonobj.put("beginnodel", objs[0]==null?"":objs[0].toString());
				jsonobj.put("beginnodeb", objs[1]==null?"":objs[1].toString());
				jsonobj.put("endnodel", objs[2]==null?"":objs[2].toString());
				jsonobj.put("endnodeb", objs[3]==null?"":objs[3].toString());
				jsonobj.put("pipesectionno", objs[4]==null?"":objs[4].toString());
				//jsonobj.put("colorlevel1", objs[5]==null?"":objs[5].toString());
				//jsonobj.put("colorlevel2", objs[6]==null?"":objs[6].toString());
				//表9-1 安全状况评估
				String table="PTEM_SECURITY_ASSESS";
				String field="RISKASSESSMENTLEVEL27512";				
				String colorlevel1=getColorlevelSecurity(table,field,pipelineno,pipesectionno);
				jsonobj.put("colorlevel1", colorlevel1);				
				field="RISKASSESSMENTLEVELWAY2";
				String colorlevel2=getColorlevelSecurity(table,field,pipelineno,pipesectionno);
				jsonobj.put("colorlevel2",colorlevel2);
				//表5-7 不同管线编号根据绝缘电阻值评定等级以不同颜色显示				
				String colorlevelRiso=getColorlevelRiso(pipelineno,pipesectionno);
				jsonobj.put("colorlevelRiso", colorlevelRiso);
				//表5-10 不同管线编号根据管地电位范围以不同颜色显示 850~1200绿色 >1200黄色 <850红色
				String colorlevelPotential=getColorlevelPotential(pipelineno,pipesectionno);
				jsonobj.put("colorlevelPotential", colorlevelPotential);
				jsonArray.add(jsonobj);
			}
			PrintWriter out = getResponse().getWriter();
			out.print(jsonArray.toString());
		}
		catch (Exception e) {
			e.printStackTrace();
		}
	}
	/**
	 * 坐标定位
	 */
	public void getGuanduanlistbyzuobiaodw(){
		try{
			String jingdu = getRequest().getParameter("jingdu");
			String weidu = getRequest().getParameter("weidu");
			String juli = getRequest().getParameter("juli");
			String zuobiaox = getRequest().getParameter("zuobiaox");
			String zuobiaoy = getRequest().getParameter("zuobiaoy");
			String julixy = getRequest().getParameter("julixy");
			//坐标X、Y转换为经纬度
			if(jingdu.equals("")||weidu.equals(""))
			{
				CoordTranf coordTranf=new CoordTranf();
				Four_Par m4=new Four_Par();//这里定义的参数是从BL --->  xy的参数 
		        m4.dX=-4117827.9819;
		        m4.dY=87682.7697;
		        m4.Cita = -0.41671168;//这里输入单位应该是度，原来的-0.250016206100是dms单位
		        m4.k=  0.999948651073;
		        Double x=Double.parseDouble(zuobiaox);
	        	Double y=Double.parseDouble(zuobiaoy);
	        	xyh mxyh = new xyh();
	            mxyh.x = x.doubleValue();//单位米
	            mxyh.y = y.doubleValue();//单位米
	            BLH  mBL = coordTranf.XY2BL(mxyh, 117, m4);
	            Double l=mBL.L;
	            Double b=mBL.B;
	            jingdu=l.toString();
	            weidu=b.toString();
	            juli=julixy;
			}
			//经纬度转换为地图经纬度
			GpsUtil gpsutil=new GpsUtil();
			BLH blh=gpsutil.ReDefineGps(jingdu, weidu);
	    	Double lmap=blh.L;
	    	Double bmap=blh.B;
	    	
	    	//查询 
			MapUtil map = new MapUtil();
			double douJingdu = lmap.doubleValue();
			double douweidu = bmap.doubleValue();
			double doujuli = Double.parseDouble(juli);
			
			double longt = map.getLongt(douJingdu, douweidu, doujuli);   
			double lat = map.getLat(douJingdu, douweidu, doujuli);         
			
			double mixlong = douJingdu-longt;
			double maxlong = douJingdu+longt;
			double mixlat = douweidu-lat;
			double maxlat = douweidu+lat;
//			String strSql = "select t.beginnodel,t.beginnodeb,t.endnodel,t.endnodeb,t.pipesectionno " +
//					"from ptem_pipesection t where t.beginnodel>="+mixlong+" " +
//					"and t.beginnodel<="+maxlong+" and t.beginnodeb>="+mixlat+" and t.beginnodeb<="+maxlat+"";
			
			String strSql = "select t.beginnodel_map,t.beginnodeb_map,t.endnodel_map,t.endnodeb_map,t.pipesectionno " +
			"from ptem_pipesection t where t.beginnodel_map>="+mixlong+" " +
			"and t.beginnodel_map<="+maxlong+" and t.beginnodeb_map>="+mixlat+" and t.beginnodeb_map<="+maxlat+"";
	
			List lists = dbService.queryDataBySql(strSql);
			JSONObject jsonzuobiaodw = new JSONObject();
			jsonzuobiaodw.put("jingdu", jingdu);
			jsonzuobiaodw.put("weidu", weidu);
			jsonzuobiaodw.put("juli", juli);
			JSONArray jsonArray = new JSONArray();
			for(int i=0;i<lists.size();i++){
				Object[] objs = (Object[])lists.get(i);
				JSONObject jsonobj = new JSONObject();
				jsonobj.put("beginnodel", objs[0]==null?"":objs[0].toString());
				jsonobj.put("beginnodeb", objs[1]==null?"":objs[1].toString());
				jsonobj.put("endnodel", objs[2]==null?"":objs[2].toString());
				jsonobj.put("endnodeb", objs[3]==null?"":objs[3].toString());
				jsonobj.put("pipesectionno", objs[3]==null?"":objs[4].toString());
				jsonArray.add(jsonobj);
			}
			jsonzuobiaodw.put("guanduandata", jsonArray);
			PrintWriter out = getResponse().getWriter();
			out.print(jsonzuobiaodw.toString());
		}
		catch (Exception e) {
			e.printStackTrace();
		}
	}
	
	/*public void getGuanduanlistbyzuobiaodw(){
		try{
			String jingdu = getRequest().getParameter("jingdu");
			String weidu = getRequest().getParameter("weidu");
			String juli = getRequest().getParameter("juli");
			MapUtil map = new MapUtil();
			double douJingdu = Double.parseDouble(jingdu);
			double douweidu = Double.parseDouble(weidu);
			double doujuli = Double.parseDouble(juli);
			
			double longt = map.getLongt(douJingdu, douweidu, doujuli);   
			double lat = map.getLat(douJingdu, douweidu, doujuli);         
			
			double mixlong = douJingdu-longt;
			double maxlong = douJingdu+longt;
			double mixlat = douweidu-lat;
			double maxlat = douweidu+lat;
			String strSql = "select t.beginnodel,t.beginnodeb,t.endnodel,t.endnodeb,t.pipesectionno " +
					"from ptem_pipesection t where t.beginnodel>="+mixlong+" " +
					"and t.beginnodel<="+maxlong+" and t.beginnodeb>="+mixlat+" and t.beginnodeb<="+maxlat+"";
			List lists = dbService.queryDataBySql(strSql);
			JSONObject jsonzuobiaodw = new JSONObject();
			jsonzuobiaodw.put("jingdu", jingdu);
			jsonzuobiaodw.put("weidu", weidu);
			jsonzuobiaodw.put("juli", juli);
			JSONArray jsonArray = new JSONArray();
			for(int i=0;i<lists.size();i++){
				Object[] objs = (Object[])lists.get(i);
				JSONObject jsonobj = new JSONObject();
				jsonobj.put("beginnodel", objs[0]==null?"":objs[0].toString());
				jsonobj.put("beginnodeb", objs[1]==null?"":objs[1].toString());
				jsonobj.put("endnodel", objs[2]==null?"":objs[2].toString());
				jsonobj.put("endnodeb", objs[3]==null?"":objs[3].toString());
				jsonobj.put("pipesectionno", objs[3]==null?"":objs[4].toString());
				jsonArray.add(jsonobj);
			}
			jsonzuobiaodw.put("guanduandata", jsonArray);
			PrintWriter out = getResponse().getWriter();
			out.print(jsonzuobiaodw.toString());
		}
		catch (Exception e) {
			e.printStackTrace();
		}
	}*/
	
	/**
	 * 框选
	 */
	public void getGuanduankuangxuan(){
		try{
			String a1 = getRequest().getParameter("a1");
			String b1 = getRequest().getParameter("b1");
			String a2 = getRequest().getParameter("a2");
			String b2 = getRequest().getParameter("b2");
			MapUtil map = new MapUtil();
			double doua1 = Double.parseDouble(a1);
			double doub1 = Double.parseDouble(b1);
			double doua2 = Double.parseDouble(a2);
			double doub2 = Double.parseDouble(b2);
			
			double mixlong = doua1;
			double maxlong = doua2;
			double mixlat = doub1;
			double maxlat = doub2;
//			String strSql = "select t.beginnodel,t.beginnodeb,t.endnodel,t.endnodeb,t.pipesectionno " +
//					"from ptem_pipesection t where t.beginnodel>="+mixlong+" " +
//					"and t.beginnodel<="+maxlong+" and t.beginnodeb>="+mixlat+" and t.beginnodeb<="+maxlat+"";
//			
			String strSql = "select t.beginnodel_map,t.beginnodeb_map,t.endnodel_map,t.endnodeb_map,t.pipesectionno " +
			"from ptem_pipesection t where t.beginnodel>="+mixlong+" " +
			"and t.beginnodel<="+maxlong+" and t.beginnodeb>="+mixlat+" and t.beginnodeb<="+maxlat+"";
		
			List lists = dbService.queryDataBySql(strSql);
			JSONObject jsonzuobiaodw = new JSONObject();
			jsonzuobiaodw.put("a1", a1);
			jsonzuobiaodw.put("a2", a2);
			jsonzuobiaodw.put("b1", b1);
			jsonzuobiaodw.put("b2", b2);
			JSONArray jsonArray = new JSONArray();
			for(int i=0;i<lists.size();i++){
				Object[] objs = (Object[])lists.get(i);
				JSONObject jsonobj = new JSONObject();
				jsonobj.put("beginnodel", objs[0]==null?"":objs[0].toString());
				jsonobj.put("beginnodeb", objs[1]==null?"":objs[1].toString());
				jsonobj.put("endnodel", objs[2]==null?"":objs[2].toString());
				jsonobj.put("endnodeb", objs[3]==null?"":objs[3].toString());
				jsonobj.put("pipesectionno", objs[3]==null?"":objs[4].toString());
				jsonArray.add(jsonobj);
			}
			jsonzuobiaodw.put("guanduandata", jsonArray);
			PrintWriter out = getResponse().getWriter();
			out.print(jsonzuobiaodw.toString());
		}
		catch (Exception e) {
			e.printStackTrace();
		}
	}
	
	public void getGuanxianTreeByZuobiao() throws IOException{
		PrintWriter out=PubMethod.GetPrintWriter();
		JSONArray jsonArray = new JSONArray();

		JSONObject guanwangroot = new JSONObject();
		guanwangroot.put("id", "root");
		guanwangroot.put("pId", "-1");
		guanwangroot.put("name", "北京管网");
		guanwangroot.put("isParent", true);
		guanwangroot.put("open", true);
		jsonArray.add(guanwangroot);
		JSONObject guanxianroot = new JSONObject();
		guanxianroot.put("id", "guanxianroot");
		guanxianroot.put("pId", "root");
		guanxianroot.put("name", "管线");
		guanwangroot.put("isParent", true);
		jsonArray.add(guanxianroot);
		
		String jingdu = getRequest().getParameter("jingdu");
		String weidu = getRequest().getParameter("weidu");
		String juli = getRequest().getParameter("juli");
		String zuobiaox = getRequest().getParameter("zuobiaox");
		String zuobiaoy = getRequest().getParameter("zuobiaoy");
		String julixy = getRequest().getParameter("julixy");
		
		//坐标X、Y转换为经纬度
		if(jingdu.equals("")||weidu.equals(""))
		{
			CoordTranf coordTranf=new CoordTranf();
			Four_Par m4=new Four_Par();//这里定义的参数是从BL --->  xy的参数 
	        m4.dX=-4117827.9819;
	        m4.dY=87682.7697;
	        m4.Cita = -0.41671168;//这里输入单位应该是度，原来的-0.250016206100是dms单位
	        m4.k=  0.999948651073;
	        Double x=Double.parseDouble(zuobiaox);
        	Double y=Double.parseDouble(zuobiaoy);
        	xyh mxyh = new xyh();
            mxyh.x = x.doubleValue();//单位米
            mxyh.y = y.doubleValue();//单位米
            BLH  mBL = coordTranf.XY2BL(mxyh, 117, m4);
            Double l=mBL.L;
            Double b=mBL.B;
            jingdu=l.toString();
            weidu=b.toString();
            juli=julixy;
		}
		
		MapUtil map = new MapUtil();
		double douJingdu = Double.parseDouble(jingdu);
		double douweidu = Double.parseDouble(weidu);
		double doujuli = Double.parseDouble(juli);
		
		double longt = map.getLongt(douJingdu, douweidu, doujuli);   
		double lat = map.getLat(douJingdu, douweidu, doujuli);         
		
		double mixlong = douJingdu-longt;
		double maxlong = douJingdu+longt;
		double mixlat = douweidu-lat;
		double maxlat = douweidu+lat;
		String strSql = "select distinct t1.pipelineno from ptem_pipesection t1 where t1.beginnodel>="+mixlong+" " +
				"and t1.beginnodel<="+maxlong+" and t1.beginnodeb>="+mixlat+" and t1.beginnodeb<="+maxlat+"";
		
		List guanxianlists = dbService.queryDataBySql(strSql);
		for(int i=0;i<guanxianlists.size();i++){
			JSONObject guanxian = new JSONObject();
			guanxian.put("id", "gx"+guanxianlists.get(i).toString());
			guanxian.put("pId", "guanxianroot");
			guanxian.put("name", guanxianlists.get(i).toString());
			jsonArray.add(guanxian);
			
			JSONObject guanduanroot = new JSONObject();
			guanduanroot.put("id", "gdroot"+guanxianlists.get(i).toString());
			guanduanroot.put("pId", "gx"+guanxianlists.get(i).toString());
			guanduanroot.put("name", "管段");
			guanduanroot.put("isParent", true);
			jsonArray.add(guanduanroot);
			
			strSql = "select t.pipesectionno from ptem_pipesection t where " +
					"t.PIPELINENO='"+guanxianlists.get(i).toString()+"' and t.pipesectionno in " +
					"(select distinct t1.pipesectionno from ptem_pipesection t1 where t1.beginnodel>="+mixlong+" " +
					"and t1.beginnodel<="+maxlong+" and t1.beginnodeb>="+mixlat+" and t1.beginnodeb<="+maxlat+")";
			List guanduanList = dbService.queryDataBySql(strSql);
			for(int j=0;j<guanduanList.size();j++){
				JSONObject guanduan = new JSONObject();
				guanduan.put("id", "gd"+guanduanList.get(j)==null?"":guanduanList.get(j).toString());
				guanduan.put("pId", "gdroot"+guanxianlists.get(i).toString());
				guanduan.put("name", guanduanList.get(j)==null?"":guanduanList.get(j).toString());
				guanduan.put("isParent", false);
				jsonArray.add(guanduan);
			}
		}
		out.print(jsonArray.toString());
	}
	
	public void getGuanxianTreeByKuangxuan() throws IOException{
		PrintWriter out=PubMethod.GetPrintWriter();
		JSONArray jsonArray = new JSONArray();

		JSONObject guanwangroot = new JSONObject();
		guanwangroot.put("id", "root");
		guanwangroot.put("pId", "-1");
		//guanwangroot.put("name", "北京管网");
		guanwangroot.put("name", "框选结果");
		guanwangroot.put("isParent", true);
		guanwangroot.put("open", true);
		jsonArray.add(guanwangroot);
		JSONObject guanxianroot = new JSONObject();
		//guanxianroot.put("id", "guanxianroot");
		guanxianroot.put("id", "guanxianrootR");
		guanxianroot.put("pId", "root");
		guanxianroot.put("name", "管线");
		guanwangroot.put("isParent", true);
		jsonArray.add(guanxianroot);
		
		String a1 = getRequest().getParameter("a1");
		String b1 = getRequest().getParameter("b1");
		String a2 = getRequest().getParameter("a2");
		String b2 = getRequest().getParameter("b2");
		MapUtil map = new MapUtil();
		double doua1 = Double.parseDouble(a1);
		double doub1 = Double.parseDouble(b1);
		double doua2 = Double.parseDouble(a2);
		double doub2 = Double.parseDouble(b2);
		
		double mixlong = doua1;
		double maxlong = doua2;
		double mixlat = doub2;
		double maxlat = doub1;
		double temp = 0;
		if (mixlat>maxlat){
			temp = mixlat;
			mixlat = maxlat;
			maxlat = temp;
		}
		String strSql = "select distinct t1.pipelineno from ptem_pipesection t1 where t1.beginnodel>="+mixlong+" " +
		"and t1.beginnodel<="+maxlong+" and t1.beginnodeb>="+mixlat+" and t1.beginnodeb<="+maxlat+"";

		List guanxianlists = dbService.queryDataBySql(strSql);
		for(int i=0;i<guanxianlists.size();i++){
			JSONObject guanxian = new JSONObject();
			guanxian.put("id", "gx"+guanxianlists.get(i).toString());
			//guanxian.put("pId", "guanxianroot");
			guanxian.put("pId", "guanxianrootR");
			guanxian.put("name", guanxianlists.get(i).toString());
			jsonArray.add(guanxian);
			
			JSONObject guanduanroot = new JSONObject();
			guanduanroot.put("id", "gdroot"+guanxianlists.get(i).toString());
			guanduanroot.put("pId", "gx"+guanxianlists.get(i).toString());
			guanduanroot.put("name", "管段");
			guanduanroot.put("isParent", true);
			jsonArray.add(guanduanroot);
			
			strSql = "select t.pipesectionno from ptem_pipesection t where " +
					"t.PIPELINENO='"+guanxianlists.get(i).toString()+"' and t.pipesectionno in " +
					"(select distinct t1.pipesectionno from ptem_pipesection t1 where t1.beginnodel>="+mixlong+" " +
					"and t1.beginnodel<="+maxlong+" and t1.beginnodeb>="+mixlat+" and t1.beginnodeb<="+maxlat+")";
			List guanduanList = dbService.queryDataBySql(strSql);
			for(int j=0;j<guanduanList.size();j++){
				JSONObject guanduan = new JSONObject();
				guanduan.put("id", "gd"+guanduanList.get(j)==null?"":guanduanList.get(j).toString());
				guanduan.put("pId", "gdroot"+guanxianlists.get(i).toString());
				guanduan.put("name", guanduanList.get(j)==null?"":guanduanList.get(j).toString());
				guanduan.put("isParent", false);
				jsonArray.add(guanduan);
			}
		}
		out.print(jsonArray.toString());
	}
	
	
	/**
	 * 获得选线信息
	 */
	public void getDrawGuanduaninfo(){
		try{
			PrintWriter out = getResponse().getWriter();
			String guanxianid = getRequest().getParameter("guanxianid");
			String colorfield = getRequest().getParameter("colorfield");
			String strWhere = "";
			String strIsshowWhere = "";
			if (!guanxianid.equals("")){
				strWhere = " and  t.pipelineno>'"+guanxianid+"'";
			}
			String colorSql = "";
			String leftSql = "";
			if (colorfield!=null&&colorfield.equals("fushifhxtpj")){
				colorSql = ",t1.corrosiondefendlevel  as colorlevel ";
				leftSql = " left join PTEM_CORROSIONDEFEND_EVALUATE t1 on t1.pipeno=t.pipesectionno  ";
				strIsshowWhere +=" and t1.pipeno is not null ";
			}else if(colorfield!=null&&colorfield.equals("fengxianpg")){
				colorSql = ",t1.riskassessmentlevelway2  as colorlevel ";
				leftSql = " left join PTEM_SECURITY_ASSESS t1 on t1.PIPENETNO=t.pipesectionno  ";
				strIsshowWhere +=" and t1.PIPENETNO is not null ";
			}
			String strSql = "select t.pipelineno from (select pipelineno from ptem_pipeline order by pipelineno) t where rownum=1 "+strWhere+"  ";
			List guanxianlists = dbService.queryDataBySql(strSql);
			JSONObject jsonroot = new JSONObject();
			if (guanxianlists.size()>0){
				guanxianid = guanxianlists.get(0).toString();
				strSql = "select t.beginnodel,t.beginnodeb,t.endnodel,t.endnodeb,t.pipesectionno" +colorSql
				+" from ptem_pipesection t "+leftSql+" where t.pipelineno='"+guanxianid+"' "+strIsshowWhere;
				List lists = dbService.queryDataBySql(strSql);
				JSONArray jsonArray = new JSONArray();
				for(int i=0;i<lists.size();i++){
					Object[] objs = (Object[])lists.get(i);
					JSONObject jsonobj = new JSONObject();
					jsonobj.put("beginnodel", objs[0]==null?"":objs[0].toString());
					jsonobj.put("beginnodeb", objs[1]==null?"":objs[1].toString());
					jsonobj.put("endnodel", objs[2]==null?"":objs[2].toString());
					jsonobj.put("endnodeb", objs[3]==null?"":objs[3].toString());
					jsonobj.put("pipesectionno", objs[4]==null?"":objs[4].toString());
					if (!colorSql.equals("")){
						jsonobj.put("color", objs[5]==null?"1":objs[5].toString());
					}
					jsonArray.add(jsonobj);
				}
				jsonroot.put("result", "success");
				jsonroot.put("guanduandata", jsonArray);
				jsonroot.put("guanxianid", guanxianid);
				out.print(jsonroot.toString());
			}
			else{
				jsonroot.put("result", "false");
				out.print(jsonroot.toString());
			}
		}
		catch (Exception e) {
			e.printStackTrace();
		}
	}
	
	/**
	 * 获得选线信息
	 */
	public void drawThumbGuanxian(){
		try{
			PrintWriter out = getResponse().getWriter();
			//String strSql = "select t.beginnodel,t.beginnodeb,t.endnodel,t.endnodeb,t.pipelineno,t.id from ptem_pipeline_node t";
			String strSql = "select t.beginnodel_map,t.beginnodeb_map,t.endnodel_map,t.endnodeb_map,t.pipelineno,t.id from ptem_pipeline_node t";			
			List lists = dbService.queryDataBySql(strSql);
			JSONObject jsonroot = new JSONObject();
			JSONArray jsonArray = new JSONArray();
			for(int i=0;i<lists.size();i++){
				Object[] objs = (Object[])lists.get(i);
				JSONObject jsonobj = new JSONObject();
				jsonobj.put("beginnodel", objs[0]==null?"":objs[0].toString());
				jsonobj.put("beginnodeb", objs[1]==null?"":objs[1].toString());
				jsonobj.put("endnodel", objs[2]==null?"":objs[2].toString());
				jsonobj.put("endnodeb", objs[3]==null?"":objs[3].toString());
				jsonobj.put("id", objs[5]==null?"":objs[5].toString());
				jsonArray.add(jsonobj);
			}
			jsonroot.put("result", "success");
			jsonroot.put("guanduandata", jsonArray);
			out.print(jsonroot.toString());
		}
		catch (Exception e) {
			e.printStackTrace();
		}
	}
	
	public void getFangfucengjiancedian() throws IOException{
		PrintWriter out=PubMethod.GetPrintWriter();
		JSONArray jsonArray = new JSONArray();
		String strSql = "select t1.LONGITUDE,t1.LATITUDE from PTEM_RISOTEST_PCM_TESTDATA t1 ";
		List lists = dbService.queryDataBySql(strSql);
		int num=lists.size();
		for(int i=0;i<num;i++){
			Object[] objs = (Object[])lists.get(i);
			if (objs[0]!=null&&!objs[0].toString().equals("")){
				JSONObject jsonobj = new JSONObject();
				jsonobj.put("longitude", objs[0].toString());
				jsonobj.put("latitude", objs[1].toString());
				jsonArray.add(jsonobj);
			}
		}
		out.print(jsonArray.toString());
	}
	
}
